Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generate Makefile target to generate operator-sdk resources #363

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13.8
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.13.8
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -30,9 +30,9 @@ jobs:
uses: codecov/[email protected]
- name: Set env
run: |
echo "KUBERNETES_VERSION=v1.15.0" >> $GITHUB_ENV
echo "OPERATOR_SDK_VERSION=v0.17.0" >> $GITHUB_ENV
echo "MINIKUBE_VERSION=v1.11.0" >> $GITHUB_ENV
echo "KUBERNETES_VERSION=v1.19.13" >> $GITHUB_ENV
echo "OPERATOR_SDK_VERSION=v0.19.4" >> $GITHUB_ENV
echo "MINIKUBE_VERSION=v1.22.0" >> $GITHUB_ENV
echo "KUBERNETES_CONFIG_FILE=$HOME/.kube/config" >> $GITHUB_ENV
echo "CHANGE_MINIKUBE_NONE_USER=true" >> $GITHUB_ENV
- name: minikube setup
Expand All @@ -41,6 +41,7 @@ jobs:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
curl -Lo operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/$OPERATOR_SDK_VERSION/operator-sdk-$OPERATOR_SDK_VERSION-x86_64-linux-gnu && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/
sudo mount --make-rshared /
sudo apt-get install -y conntrack
CHANGE_MINIKUBE_NONE_USER=true
export KUBERNETES_CONFIG_FILE=$HOME/.kube/config
export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true;sudo minikube start --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=$KUBERNETES_VERSION
Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,32 @@ SHELL=/bin/bash -o pipefail
PROJECT_NAME=zookeeper-operator
EXPORTER_NAME=zookeeper-exporter
APP_NAME=zookeeper
KUBE_VERSION=1.17.5
KUBE_VERSION=1.19.13
REPO=pravega/$(PROJECT_NAME)
TEST_REPO=testzkop/$(PROJECT_NAME)
APP_REPO=pravega/$(APP_NAME)
ALTREPO=emccorp/$(PROJECT_NAME)
APP_ALTREPO=emccorp/$(APP_NAME)
OSDK_VERSION=$(shell operator-sdk version | cut -f2 -d'"')
VERSION=$(shell git describe --always --tags --dirty | tr -d "v" | sed "s/\(.*\)-g`git rev-parse --short HEAD`/\1/")
GIT_SHA=$(shell git rev-parse --short HEAD)
TEST_IMAGE=$(TEST_REPO)-testimages:$(VERSION)
DOCKER_TEST_PASS=testzkop@123
DOCKER_TEST_USER=testzkop
.PHONY: all build check clean test

all: check build
all: generate check build

generate:
[[ ${OSDK_VERSION} == v0.19* ]] || ( echo "operator-sdk version 0.19 required" ; exit 1 )
operator-sdk generate crds --crd-version v1
env GOROOT=$(shell go env GOROOT) operator-sdk generate k8s
# sync crd generated to helm-chart
echo '{{- define "crd.openAPIV3Schema" }}' > charts/zookeeper-operator/templates/_crd_openapiv3schema.tpl
echo 'openAPIV3Schema:' >> charts/zookeeper-operator/templates/_crd_openapiv3schema.tpl
sed -e '1,/openAPIV3Schema/d' deploy/crds/zookeeper.pravega.io_zookeeperclusters_crd.yaml | sed -n '/served: true/!p;//q' >> charts/zookeeper-operator/templates/_crd_openapiv3schema.tpl
echo '{{- end }}' >> charts/zookeeper-operator/templates/_crd_openapiv3schema.tpl


build: test build-go build-image

Expand Down Expand Up @@ -77,7 +89,7 @@ test-e2e-local:
operator-sdk test local ./test/e2e --operator-namespace default --up-local --go-test-flags "-v -timeout 0"

run-local:
operator-sdk up local
operator-sdk run local

login:
@docker login -u "$(DOCKER_USER)" -p "$(DOCKER_PASS)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ The list of available commands are
### Build the operator image

Requirements:
- Go 1.13+
- Go 1.16+

Use the `make` command to build the Zookeeper operator image.

Expand Down
5,167 changes: 5,167 additions & 0 deletions charts/zookeeper-operator/templates/_crd_openapiv3schema.tpl

Large diffs are not rendered by default.

4,858 changes: 0 additions & 4,858 deletions charts/zookeeper-operator/templates/_helpers.tpl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pravega/zookeeper-operator/pkg/yamlexporter"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

var (
Expand Down
8 changes: 5 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"runtime"
"strings"

"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/operator-framework/operator-sdk/pkg/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/leader"
sdkVersion "github.com/operator-framework/operator-sdk/version"
Expand All @@ -28,9 +30,9 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client/config"
logf "sigs.k8s.io/controller-runtime/pkg/log"
logz "sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

var (
Expand All @@ -57,7 +59,7 @@ func main() {
// implementing the logr.Logger interface. This logger will
// be propagated through the whole operator, generating
// uniform and structured logs.
logf.SetLogger(logf.ZapLogger(false))
logf.SetLogger(logz.New(logz.UseDevMode(false)))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing this? will it cause any logging format change in operator logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch - missed a local commit here

printVersion()

Expand Down
Loading