- Notifications
You must be signed in to change notification settings - Fork25
modified memcached operator according to run bundle integration#86
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
laxmikantbpandhare merged 4 commits intooperator-framework:mainfromlaxmikantbpandhare:update-tutorial-mem-exJun 3, 2022
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
26e16e5 modified memcached operator according to run bundle integration and w…
laxmikantbpandhare55a7365 modified tutorial
laxmikantbpandhare17e11c5 updated according to review comments
laxmikantbpandhare946a64c updated according to review comments
laxmikantbpandhareFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -542,6 +542,14 @@ You can run the operator in a couple of ways. You can run it locally where the | ||
| operator runs on your development machine and talks to the cluster. Or it can | ||
| build images of your operator and run it directly in the cluster. | ||
| There are three ways to run the operator: | ||
| * Running the operator in the cluster | ||
| * Running locally outside the cluster | ||
| * Managed by the [Operator Lifecycle Manager (OLM)](https://sdk.operatorframework.io/docs/olm-integration/tutorial-bundle/#enabling-olm) in [bundle](https://sdk.operatorframework.io/docs/olm-integration/quickstart-bundle/) format | ||
| In this section we will: | ||
| * install the CRD | ||
| @@ -566,17 +574,17 @@ conveniently build your and push your operator's image to registry. In our | ||
| example, we are using `quay.io`, but any docker registry should work. | ||
| ``` | ||
| make docker-build docker-push IMG=quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1 | ||
| ``` | ||
| This will build the docker image | ||
| `quay.io/YOURUSER/memcached-quarkus-operator:v0.0.1` and push it to the registry. | ||
| You can verify it is in your docker registry: | ||
| ``` | ||
| $ docker images | grep memcached | ||
| quay.io/YOURUSER/memcached-quarkus-operatorv0.0.1 c84d2616bc1b 29 seconds ago 236MB | ||
| ``` | ||
| 2. Install the CRD | ||
| @@ -783,3 +791,50 @@ pod/memcached-sample-6c765df685-mfqnz 1/1 Running 0 | ||
| If you modify the size field of the `memcached-sample.yaml` and re-apply it. The | ||
| operator will trigger a reconcile and adjust the sample pods to the size given. | ||
| ### Deploy your Operator with OLM | ||
| First, install [OLM](https://sdk.operatorframework.io/docs/olm-integration/tutorial-bundle/#enabling-olm): | ||
| ``` | ||
| operator-sdk olm install | ||
| ``` | ||
| Bundle your operator, then build and push the bundle image. The [bundle](https://github.com/operator-framework/operator-registry/blob/v1.23.0/docs/design/operator-bundle.md#operator-bundle) target generates a bundle in the `bundle` directory containing manifests and metadata defining your operator. `bundle-build` and `bundle-push` build and push a bundle image defined by `bundle.Dockerfile`. | ||
| Before running below command export environment variables as shown below. | ||
| ``` | ||
| $ export USERNAME=<container-registry-username> | ||
| $ export VERSION=0.0.1 | ||
| $ export IMG=docker.io/$USERNAME/memcached-operator:v$VERSION // location where your operator image is hosted | ||
| $ export BUNDLE_IMG=docker.io/$USERNAME/memcached-operator-bundle:v$VERSION // location where your bundle will be hosted | ||
| ``` | ||
| ``` | ||
| make bundle bundle-build bundle-push | ||
laxmikantbpandhare marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ``` | ||
| Finally, run your bundle. If your bundle image is hosted in a registry that is private and/or has a custom CA, these [configuration steps](https://sdk.operatorframework.io/docs/olm-integration/cli-overview/#private-bundle-and-catalog-image-registries) must be completed. | ||
| ``` | ||
| operator-sdk run bundle <some-registry>/memcached-operator-bundle:v0.0.1 | ||
| ``` | ||
laxmikantbpandhare marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| The result of the above command is as below: | ||
| ``` | ||
| INFO[0009] Successfully created registry pod: docker-io-013859989-memcached-quarkus-operator-bundle-v0-1-1 | ||
| INFO[0009] Created CatalogSource: memcached-quarkus-operator-catalog | ||
| INFO[0009] OperatorGroup "operator-sdk-og" created | ||
| INFO[0009] Created Subscription: memcached-quarkus-operator-v0-1-1-sub | ||
| INFO[0013] Approved InstallPlan install-6n8vm for the Subscription: memcached-quarkus-operator-v0-1-1-sub | ||
| INFO[0013] Waiting for ClusterServiceVersion "default/memcached-quarkus-operator.v0.1.1" to reach 'Succeeded' phase | ||
| INFO[0013] Waiting for ClusterServiceVersion "default/memcached-quarkus-operator.v0.1.1" to appear | ||
| INFO[0020] Found ClusterServiceVersion "default/memcached-quarkus-operator.v0.1.1" phase: Pending | ||
| INFO[0021] Found ClusterServiceVersion "default/memcached-quarkus-operator.v0.1.1" phase: Installing | ||
| INFO[0051] Found ClusterServiceVersion "default/memcached-quarkus-operator.v0.1.1" phase: Succeeded | ||
| INFO[0051] OLM has successfully installed "memcached-quarkus-operator.v0.1.1" | ||
| ``` | ||
| Check out the [docs](https://sdk.operatorframework.io/docs/olm-integration/tutorial-bundle/) for a deep dive into operator-sdk's OLM integration. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| VERSION ?= 0.0.1 | ||
| IMAGE_TAG_BASE ?= example.com/memcached-quarkus-operator | ||
| BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) | ||
| # Image URL to use all building/pushing image targets | ||
| IMG ?= controller:latest | ||
| all: docker-build | ||
| ##@ General | ||
| # The help target prints out all targets with their descriptions organized | ||
| # beneath their categories. The categories are represented by '##@' and the | ||
| # target descriptions by '##'. The awk commands is responsible for reading the | ||
| # entire set of makefiles included in this invocation, looking for lines of the | ||
| # file as xyz: ## something, and then pretty-format the target and help. Then, | ||
| # if there's a line with ##@ something, that gets pretty-printed as a category. | ||
| # More info on the usage of ANSI control characters for terminal formatting: | ||
| # https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
| # More info on the awk command: | ||
| # http://linuxcommand.org/lc3_adv_awk.php | ||
| help: ## Display this help. | ||
| @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
| ##@ Build | ||
| docker-build: ## Build docker image with the manager. | ||
| mvn package -Dquarkus.container-image.build=true -Dquarkus.container-image.image=${IMG} | ||
| docker-push: ## Push docker image with the manager. | ||
| mvn package -Dquarkus.container-image.push=true -Dquarkus.container-image.image=${IMG} | ||
| ##@ Deployment | ||
| install: ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
| @$(foreach file, $(wildcard target/kubernetes/*-v1.yml), kubectl apply -f $(file);) | ||
| uninstall: ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. | ||
| @$(foreach file, $(wildcard target/kubernetes/*-v1.yml), kubectl delete -f $(file);) | ||
| deploy: ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
| kubectl apply -f target/kubernetes/kubernetes.yml | ||
| undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||
| kubectl delete -f target/kubernetes/kubernetes.yml | ||
| ##@Bundle | ||
| .PHONY: bundle | ||
| bundle: ## Generate bundle manifests and metadata, then validate generated files. | ||
| ## marker | ||
| cat target/kubernetes/memcacheds.cache.example.com-v1.yml target/kubernetes/kubernetes.yml | operator-sdk generate bundle -q --overwrite --version 0.1.1 --default-channel=stable --channels=stable --package=memcached-quarkus-operator | ||
| operator-sdk bundle validate ./bundle | ||
| .PHONY: bundle-build | ||
| bundle-build: ## Build the bundle image. | ||
| docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . | ||
| .PHONY: bundle-push | ||
| bundle-push: ## Push the bundle image. | ||
| docker push $(BUNDLE_IMG) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM scratch | ||
| # Core bundle labels. | ||
| LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 | ||
| LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ | ||
| LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ | ||
| LABEL operators.operatorframework.io.bundle.package.v1=memcached-quarkus-operator | ||
| LABEL operators.operatorframework.io.bundle.channels.v1=stable | ||
| LABEL operators.operatorframework.io.bundle.channel.default.v1=stable | ||
| LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.21.0+git | ||
| LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 | ||
| LABEL operators.operatorframework.io.metrics.project_layout=quarkus.javaoperatorsdk.io/v1-alpha | ||
| # Copy files to locations specified by labels. | ||
| COPY bundle/manifests /manifests/ | ||
| COPY bundle/metadata /metadata/ |
40 changes: 40 additions & 0 deletions...ata/quarkus/memcached-quarkus-operator/bundle/manifests/cache.example.com_memcacheds.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| creationTimestamp: null | ||
| name: memcacheds.cache.example.com | ||
| spec: | ||
| group: cache.example.com | ||
| names: | ||
| kind: Memcached | ||
| plural: memcacheds | ||
| singular: memcached | ||
| scope: Namespaced | ||
| versions: | ||
| - name: v1 | ||
| schema: | ||
| openAPIV3Schema: | ||
| properties: | ||
| spec: | ||
| properties: | ||
| size: | ||
| type: integer | ||
| type: object | ||
| status: | ||
| properties: | ||
| nodes: | ||
| items: | ||
| type: string | ||
| type: array | ||
| type: object | ||
| type: object | ||
| served: true | ||
| storage: true | ||
| subresources: | ||
| status: {} | ||
| status: | ||
| acceptedNames: | ||
| kind: "" | ||
| plural: "" | ||
| conditions: null | ||
| storedVersions: null |
12 changes: 12 additions & 0 deletions...ts/memcached-quarkus-operator-operator-view_rbac.authorization.k8s.io_v1_rolebinding.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| creationTimestamp: null | ||
| name: memcached-quarkus-operator-operator-view | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: view | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: memcached-quarkus-operator-operator |
25 changes: 25 additions & 0 deletions...hed-quarkus-operator/bundle/manifests/memcached-quarkus-operator-operator_v1_service.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| annotations: | ||
| app.quarkus.io/build-timestamp: 2022-06-03 - 17:56:59 +0000 | ||
| prometheus.io/path: /q/metrics | ||
| prometheus.io/port: "8080" | ||
| prometheus.io/scheme: http | ||
| prometheus.io/scrape: "true" | ||
| creationTimestamp: null | ||
| labels: | ||
| app.kubernetes.io/name: memcached-quarkus-operator-operator | ||
| app.kubernetes.io/version: 0.0.1-SNAPSHOT | ||
| name: memcached-quarkus-operator-operator | ||
| spec: | ||
| ports: | ||
| - name: http | ||
| port: 80 | ||
| targetPort: 8080 | ||
| selector: | ||
| app.kubernetes.io/name: memcached-quarkus-operator-operator | ||
| app.kubernetes.io/version: 0.0.1-SNAPSHOT | ||
| type: ClusterIP | ||
| status: | ||
| loadBalancer: {} |
128 changes: 128 additions & 0 deletions...d-quarkus-operator/bundle/manifests/memcached-quarkus-operator.clusterserviceversion.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| apiVersion: operators.coreos.com/v1alpha1 | ||
| kind: ClusterServiceVersion | ||
| metadata: | ||
| annotations: | ||
| alm-examples: '[]' | ||
| capabilities: Basic Install | ||
| operators.operatorframework.io/builder: operator-sdk-v1.21.0+git | ||
| operators.operatorframework.io/project_layout: quarkus.javaoperatorsdk.io/v1-alpha | ||
| name: memcached-quarkus-operator.v0.1.1 | ||
| namespace: placeholder | ||
| spec: | ||
| apiservicedefinitions: {} | ||
| customresourcedefinitions: | ||
| owned: | ||
| - kind: Memcached | ||
| name: memcacheds.cache.example.com | ||
| version: v1 | ||
| description: Memcached Quarkus Operator description. TODO. | ||
| displayName: Memcached Quarkus Operator | ||
| icon: | ||
| - base64data: "" | ||
| mediatype: "" | ||
| install: | ||
| spec: | ||
| clusterPermissions: | ||
| - rules: | ||
| - apiGroups: | ||
| - cache.example.com | ||
| resources: | ||
| - memcacheds | ||
| - memcacheds/status | ||
| - memcacheds/finalizers | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - delete | ||
| - patch | ||
| - update | ||
| - apiGroups: | ||
| - apiextensions.k8s.io | ||
| resources: | ||
| - customresourcedefinitions | ||
| verbs: | ||
| - get | ||
| - list | ||
| serviceAccountName: memcached-quarkus-operator-operator | ||
| deployments: | ||
| - label: | ||
| app.kubernetes.io/name: memcached-quarkus-operator-operator | ||
| app.kubernetes.io/version: 0.0.1-SNAPSHOT | ||
| name: memcached-quarkus-operator-operator | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: memcached-quarkus-operator-operator | ||
| app.kubernetes.io/version: 0.0.1-SNAPSHOT | ||
| strategy: {} | ||
| template: | ||
| metadata: | ||
| annotations: | ||
| app.quarkus.io/build-timestamp: 2022-06-03 - 17:56:59 +0000 | ||
| prometheus.io/path: /q/metrics | ||
| prometheus.io/port: "8080" | ||
| prometheus.io/scheme: http | ||
| prometheus.io/scrape: "true" | ||
| labels: | ||
| app.kubernetes.io/name: memcached-quarkus-operator-operator | ||
| app.kubernetes.io/version: 0.0.1-SNAPSHOT | ||
| spec: | ||
| containers: | ||
| - env: | ||
| - name: KUBERNETES_NAMESPACE | ||
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: metadata.namespace | ||
| image: quay.io/lpandhar/memcached-quarkus-operator:v0.1.1 | ||
| imagePullPolicy: Always | ||
| livenessProbe: | ||
| failureThreshold: 3 | ||
| httpGet: | ||
| path: /q/health/live | ||
| port: 8080 | ||
| scheme: HTTP | ||
| periodSeconds: 30 | ||
| successThreshold: 1 | ||
| timeoutSeconds: 10 | ||
| name: memcached-quarkus-operator-operator | ||
| ports: | ||
| - containerPort: 8080 | ||
| name: http | ||
| protocol: TCP | ||
| readinessProbe: | ||
| failureThreshold: 3 | ||
| httpGet: | ||
| path: /q/health/ready | ||
| port: 8080 | ||
| scheme: HTTP | ||
| periodSeconds: 30 | ||
| successThreshold: 1 | ||
| timeoutSeconds: 10 | ||
| resources: {} | ||
| serviceAccountName: memcached-quarkus-operator-operator | ||
| strategy: deployment | ||
| installModes: | ||
| - supported: false | ||
| type: OwnNamespace | ||
| - supported: false | ||
| type: SingleNamespace | ||
| - supported: false | ||
| type: MultiNamespace | ||
| - supported: true | ||
| type: AllNamespaces | ||
| keywords: | ||
| - memcached-quarkus-operator | ||
| links: | ||
| - name: Memcached Quarkus Operator | ||
| url: https://memcached-quarkus-operator.domain | ||
| maintainers: | ||
| - email: your@email.com | ||
| name: Maintainer Name | ||
| maturity: alpha | ||
| provider: | ||
| name: Provider Name | ||
| url: https://your.domain | ||
| version: 0.1.1 |
11 changes: 11 additions & 0 deletionstestdata/quarkus/memcached-quarkus-operator/bundle/metadata/annotations.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| annotations: | ||
| # Core bundle annotations. | ||
| operators.operatorframework.io.bundle.mediatype.v1: registry+v1 | ||
| operators.operatorframework.io.bundle.manifests.v1: manifests/ | ||
| operators.operatorframework.io.bundle.metadata.v1: metadata/ | ||
| operators.operatorframework.io.bundle.package.v1: memcached-quarkus-operator | ||
| operators.operatorframework.io.bundle.channels.v1: stable | ||
| operators.operatorframework.io.bundle.channel.default.v1: stable | ||
| operators.operatorframework.io.metrics.builder: operator-sdk-v1.21.0+git | ||
| operators.operatorframework.io.metrics.mediatype.v1: metrics+v1 | ||
| operators.operatorframework.io.metrics.project_layout: quarkus.javaoperatorsdk.io/v1-alpha |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.