# memcached-operator **Repository Path**: wilds/memcached-operator ## Basic Information - **Project Name**: memcached-operator - **Description**: operator framework sdk - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-29 - **Last Updated**: 2024-04-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # install ``` git clone https://github.com/operator-framework/operator-sdk cd operator-sdk git checkout master make install ``` ``` curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash ``` ## operator-sdk olm status ``` [root@openfuyao-0004 nginx-operator]# operator-sdk olm status --olm-namespace=olm INFO[0000] Fetching CRDs for version "v0.27.0" INFO[0000] Fetching resources for resolved version "v0.27.0" INFO[0002] Successfully got OLM status for version "v0.27.0" NAME NAMESPACE KIND STATUS olm-operators olm OperatorGroup Installed operators.operators.coreos.com CustomResourceDefinition Installed operatorconditions.operators.coreos.com CustomResourceDefinition Installed catalog-operator olm Deployment Installed olm-operator-binding-olm ClusterRoleBinding Installed operatorhubio-catalog olm CatalogSource Installed subscriptions.operators.coreos.com CustomResourceDefinition Installed system:controller:operator-lifecycle-manager ClusterRole Installed installplans.operators.coreos.com CustomResourceDefinition Installed operatorgroups.operators.coreos.com CustomResourceDefinition Installed olm Namespace Installed cluster OLMConfig Installed packageserver olm ClusterServiceVersion Installed operators Namespace Installed catalogsources.operators.coreos.com CustomResourceDefinition Installed olm-operator olm Deployment Installed global-operators operators OperatorGroup Installed aggregate-olm-view ClusterRole Installed aggregate-olm-edit ClusterRole Installed olmconfigs.operators.coreos.com CustomResourceDefinition Installed clusterserviceversions.operators.coreos.com CustomResourceDefinition Installed olm-operator-serviceaccount olm ServiceAccount Installed [root@openfuyao-0004 nginx-operator]# ``` ## init ``` [root@openfuyao-0004 memcached-operator]# operator-sdk init --domain wasmdoors --repo gitee.com/wilds/memcached-operator Writing kustomize manifests for you to edit... Writing scaffold for you to edit... Get controller runtime: $ go get sigs.k8s.io/controller-runtime@v0.15.0 Update dependencies: $ go mod tidy Next: define a resource with: $ operator-sdk create api ``` ## Create a simple Memcached API: ``` [root@openfuyao-0004 memcached-operator]# operator-sdk create api --group cache --version v1alpha1 --kind Memcached --resource --controller Writing kustomize manifests for you to edit... Writing scaffold for you to edit... api/v1alpha1/memcached_types.go api/v1alpha1/groupversion_info.go internal/controller/suite_test.go internal/controller/memcached_controller.go Update dependencies: $ go mod tidy Running make: $ make generate mkdir -p /opt/paul/code/wilds/memcached-operator/bin test -s /opt/paul/code/wilds/memcached-operator/bin/controller-gen && /opt/paul/code/wilds/memcached-operator/bin/controller-gen --version | grep -q v0.12.0 || \ GOBIN=/opt/paul/code/wilds/memcached-operator/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0 /opt/paul/code/wilds/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." Next: implement your new API and generate the manifests (e.g. CRDs,CRs) with: $ make manifests ``` ## Build and push your operator’s image: ``` [root@openfuyao-0004 memcached-operator]# make docker-build docker-push IMG="wasmdoors/memcached-operator:v1.0.0" /opt/paul/code/wilds/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases /opt/paul/code/wilds/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." go fmt ./... go vet ./... test -s /opt/paul/code/wilds/memcached-operator/bin/setup-envtest || GOBIN=/opt/paul/code/wilds/memcached-operator/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240327193027-21368602d84b go: sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240327193027-21368602d84b requires go >= 1.22.0; switching to go1.22.1 go: downloading go1.22.1 (linux/amd64) KUBEBUILDER_ASSETS="/opt/paul/code/wilds/memcached-operator/bin/k8s/1.27.1-linux-amd64" go test ./... -coverprofile cover.out ? gitee.com/wilds/memcached-operator/api/v1alpha1 [no test files] ? gitee.com/wilds/memcached-operator/cmd [no test files] ok gitee.com/wilds/memcached-operator/internal/controller 0.016s coverage: 0.0% of statements docker build -t wasmdoors/memcached-operator:v1.0.0 . Sending build context to Docker daemon 12.44MB Step 1/16 : FROM golang:1.20 as builder ---> d5beeac3653f ... Successfully built c3c5304b29ae Successfully tagged wasmdoors/memcached-operator:v1.0.0 docker push wasmdoors/memcached-operator:v1.0.0 The push refers to repository [docker.io/wasmdoors/memcached-operator] 20580467c26d: Pushed ... 70c35736547b: Layer already exists v1.0: digest: sha256:0e1dfc6e6c4e9f48e35f8a9fedc4b98e356cd41bb401b3157a5f092c2bb56890 size: 2402 [root@openfuyao-0004 memcached-operator]# ``` ## make bundle命令创建Operator捆绑包清单,该命令调用多个命令,其中包括Operator SDK generate bundle和bundle validate子命令. Operator的捆绑包清单描述了如何显示、创建和管理应用程序。make bundle命令在Operator项目中创建以下文件和目录: - 包含ClusterServiceVersion对象的捆绑包清单目录,名为bundle/manifests - 名为bundle/metadata的捆绑包元数据目录 - config/crd目录中的所有自定义资源定义(CRD) - 一个Dockerfile bundle.Dockerfile 然后,使用operator-sdk bundle validate自动验证这些文件,以确保磁盘上的捆绑包的格式是正确的。 Bundle your operator, then build and push the bundle image ``` [root@openfuyao-0004 memcached-operator]# make bundle IMG="wasmdoors/memcached-operator:v1.0.0" test -s /opt/paul/code/wilds/memcached-operator/bin/controller-gen && /opt/paul/code/wilds/memcached-operator/bin/controller-gen --version | grep -q v0.12.0 || \ GOBIN=/opt/paul/code/wilds/memcached-operator/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0 /opt/paul/code/wilds/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases test -s /opt/paul/code/wilds/memcached-operator/bin/kustomize || GOBIN=/opt/paul/code/wilds/memcached-operator/bin GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@v5.0.1 /usr/local/bin/operator-sdk generate kustomize manifests -q Display name for the operator (required): > memcached-operator Description for the operator (required): > memcached-operator Provider's name for the operator (required): > wilds Any relevant URL for the provider name (optional): > Comma-separated list of keywords for your operator (required): > memcached-operator Comma-separated list of maintainers and their emails (e.g. 'name1:email1, name2:email2') (required): > javadoors:javadoors@126.com cd config/manager && /opt/paul/code/wilds/memcached-operator/bin/kustomize edit set image controller=wasmdoors/memcached-operator:v1.0.0 /opt/paul/code/wilds/memcached-operator/bin/kustomize build config/manifests | /usr/local/bin/operator-sdk generate bundle -q --overwrite --version 0.0.1 # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. WARN[0000] ClusterServiceVersion validation: [CSVFileNotValid] (memcached-operator.v0.0.1) csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. Otherwise, it would mean that your operator project can be distributed and installed in any cluster version available, which is not necessarily the case for all projects. INFO[0000] Creating bundle/metadata/annotations.yaml INFO[0000] Creating bundle.Dockerfile INFO[0000] Bundle metadata generated successfully /usr/local/bin/operator-sdk bundle validate ./bundle WARN[0000] Warning: Value : (memcached-operator.v0.0.1) csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. Otherwise, it would mean that your operator project can be distributed and installed in any cluster version available, which is not necessarily the case for all projects. INFO[0000] All validation tests have completed successfully ``` 上面执行后在manifest目录下没有生成预期的文件,可使用如下命令替换: ``` .PHONY: bundle bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. $(OPERATOR_SDK) generate kustomize manifests -q cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) $(OPERATOR_SDK) bundle validate ./bundle operator-sdk generate kustomize manifests -q cd config/manager && kustomize edit set image controller="wasmdoors/memcached-operator:v1.0.0" kustomize build config/manifests | operator-sdk generate bundle --version 1.0.0 operator-sdk bundle validate ./bundle ``` ## 以下命令来构建和推送捆绑包镜像。OLM使用索引镜像来消耗Operator捆绑包,该镜像引用一个或多个捆绑包镜像。 ``` [root@openfuyao-0004 memcached-operator]# make bundle-build bundle-push BUNDLE_IMG="wasmdoors/memcached-operator-bundle:v1.0.0" docker build -f bundle.Dockerfile -t wasmdoors/memcached-operator-bundle:v1.0.0 . Sending build context to Docker daemon 80.07MB Step 1/14 : FROM scratch ---> ... Successfully built 79372052e484 Successfully tagged wasmdoors/memcached-operator-bundle:v1.0.0 make docker-push IMG=wasmdoors/memcached-operator-bundle:v1.0.0 make[1]: Entering directory '/opt/paul/code/wilds/memcached-operator' docker push wasmdoors/memcached-operator-bundle:v1.0.0 The push refers to repository [docker.io/wasmdoors/memcached-operator-bundle] 4f3cdf220778: Pushed ... v1.0: digest: sha256:5a3e9e079c7e9d0fad621ae7b5bd80586669206fab50c14c7d2f8ce65a762fae size: 939 make[1]: Leaving directory '/opt/paul/code/wilds/memcached-operator' [root@openfuyao-0004 memcached-operator]# ``` ## 推送捆绑包镜像: ``` $ docker push docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 ``` ## Run your bundle. ``` [root@openfuyao-0004 memcached-operator]# kubectl create namespace memcached-operator namespace/memcached-operator created ``` ``` [root@openfuyao-0004 memcached-operator]# operator-sdk run bundle -n memcached-operator docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 INFO[0036] Creating a File-Based Catalog of the bundle "docker.io/wasmdoors/memcached-operator-bundle:v1.0.0" INFO[0038] Generated a valid File-Based Catalog INFO[0043] Created registry pod: docker-io-wasmdoors-memcached-operator-bundle-v1-0 INFO[0043] Created CatalogSource: memcached-operator-catalog INFO[0043] OperatorGroup "operator-sdk-og" created INFO[0043] Created Subscription: memcached-operator-v0-0-1-sub FATA[0120] Failed to run bundle: install plan is not available for the subscription memcached-operator-v0-0-1-sub: context deadline exceeded [root@openfuyao-0004 memcached-operator]# ``` This command performs the following actions: - Create an index image with your bundle image injected. - Create a catalog source that points to your new index image, which enables OperatorHub to discover your Operator. - Deploy your Operator to your cluster by creating an Operator group, subscription, install plan, and all other required objects, including RBAC. ### CatalogSource ``` [root@openfuyao-0004 memcached-operator]# kubectl get CatalogSource memcached-operator-catalog -n memcached-operator -oyaml apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: annotations: operators.operatorframework.io/index-image: quay.io/operator-framework/opm:latest operators.operatorframework.io/injected-bundles: '[{"imageTag":"docker.io/wasmdoors/memcached-operator-bundle:v1.0.0","mode":"semver"}]' operators.operatorframework.io/registry-pod-name: docker-io-wasmdoors-memcached-operator-bundle-v1-0 creationTimestamp: "2024-03-30T02:08:28Z" generation: 2 name: memcached-operator-catalog namespace: memcached-operator resourceVersion: "11799200" uid: bd018d36-3208-43e9-b935-af6742eb0ed8 spec: address: 172.17.135.12:50051 displayName: memcached-operator grpcPodConfig: securityContextConfig: legacy icon: base64data: "" mediatype: "" publisher: operator-sdk secrets: - "" sourceType: grpc status: connectionState: address: 172.17.135.12:50051 lastConnect: "2024-03-30T02:23:32Z" lastObservedState: READY registryService: createdAt: "2024-03-30T02:08:32Z" protocol: grpc [root@openfuyao-0004 memcached-operator]# ``` ### OperatorGroup ``` [root@openfuyao-0004 memcached-operator]# kubectl get OperatorGroup operator-sdk-og -n memcached-operator -oyaml apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: creationTimestamp: "2024-03-30T02:08:32Z" generation: 1 name: operator-sdk-og namespace: memcached-operator resourceVersion: "11797881" uid: 02b55792-eab8-48ae-8965-4d501ea40d62 spec: upgradeStrategy: Default status: lastUpdated: "2024-03-30T02:08:32Z" namespaces: - "" ``` ### Subscription ``` [root@openfuyao-0004 bundle]# kubectl get subs -A NAMESPACE NAME PACKAGE SOURCE CHANNEL memcached-operator memcached-operator-v0-0-1-sub memcached-operator memcached-operator-catalog operator-sdk-run-bundle [root@openfuyao-0004 bundle]# kubectl get subs memcached-operator-v0-0-1-sub -n memcached-operator -oyaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: creationTimestamp: "2024-03-30T03:18:41Z" generation: 1 labels: operators.coreos.com/memcached-operator.memcached-operator: "" name: memcached-operator-v0-0-1-sub namespace: memcached-operator resourceVersion: "11804243" uid: 2f390a20-67ef-4240-b32b-980e128d8cd8 spec: channel: operator-sdk-run-bundle installPlanApproval: Manual name: memcached-operator source: memcached-operator-catalog sourceNamespace: memcached-operator startingCSV: memcached-operator.v0.0.1 status: catalogHealth: - catalogSourceRef: apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource name: memcached-operator-catalog namespace: memcached-operator resourceVersion: "11804015" uid: 8c95829b-ddb6-4158-9207-b36e061a4c7c healthy: true lastUpdated: "2024-03-30T03:18:45Z" - catalogSourceRef: apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource name: operatorhubio-catalog namespace: olm resourceVersion: "11802644" uid: b4d23079-d7db-439c-abc9-8ba907cf5724 healthy: true lastUpdated: "2024-03-30T03:18:45Z" conditions: - reason: UnpackingInProgress status: "True" type: BundleUnpacking - lastTransitionTime: "2024-03-30T03:18:45Z" message: all available catalogsources are healthy reason: AllCatalogSourcesHealthy status: "False" type: CatalogSourcesUnhealthy - message: 'bundle unpacking failed. Reason: BackoffLimitExceeded, and Message: Job has reached the specified backoff limit' reason: BundleUnpackFailed status: "True" type: BundleUnpackFailed lastUpdated: "2024-03-30T03:20:05Z" [root@openfuyao-0004 bundle]# ``` ### Jobs ``` [root@openfuyao-0004 bundle]# kubectl get jobs ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 -n memcached-operator -oyaml apiVersion: batch/v1 kind: Job metadata: creationTimestamp: "2024-03-30T03:18:45Z" generation: 1 labels: olm.managed: "true" operatorframework.io/bundle-unpack-ref: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 name: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 namespace: memcached-operator ownerReferences: - apiVersion: v1 blockOwnerDeletion: false controller: false kind: ConfigMap name: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 uid: b8c6d799-62a6-441b-933a-a2da04d27a07 resourceVersion: "11804233" uid: 53a5fb8c-45ef-4b80-b560-5b3a99db4649 spec: activeDeadlineSeconds: 600 backoffLimit: 3 completionMode: NonIndexed completions: 1 manualSelector: false parallelism: 1 podReplacementPolicy: TerminatingOrFailed selector: matchLabels: batch.kubernetes.io/controller-uid: 53a5fb8c-45ef-4b80-b560-5b3a99db4649 suspend: false template: metadata: creationTimestamp: null labels: batch.kubernetes.io/controller-uid: 53a5fb8c-45ef-4b80-b560-5b3a99db4649 batch.kubernetes.io/job-name: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 controller-uid: 53a5fb8c-45ef-4b80-b560-5b3a99db4649 job-name: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 olm.managed: "true" name: ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 spec: containers: - command: - opm - alpha - bundle - extract - -m - /bundle/ - -n - memcached-operator - -c - ef748abd0241b90fe6608d8d5e3617dc5d0c78802e1a6698d94fee7f10659b3 - -z env: - name: CONTAINER_IMAGE value: docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 image: quay.io/operator-framework/opm:latest imagePullPolicy: Always name: extract resources: requests: cpu: 10m memory: 50Mi securityContext: allowPrivilegeEscalation: false capabilities: drop: - ALL terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /bundle name: bundle dnsPolicy: ClusterFirst imagePullSecrets: - {} initContainers: - command: - /bin/cp - -Rv - /bin/cpb - /util/cpb image: quay.io/operator-framework/olm@sha256:1b6002156f568d722c29138575733591037c24b4bfabc67946f268ce4752c3e6 imagePullPolicy: IfNotPresent name: util resources: requests: cpu: 10m memory: 50Mi securityContext: allowPrivilegeEscalation: false capabilities: drop: - ALL terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /util name: util - command: - /util/cpb - /bundle image: docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 imagePullPolicy: Always name: pull resources: requests: cpu: 10m memory: 50Mi securityContext: allowPrivilegeEscalation: false capabilities: drop: - ALL terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /bundle name: bundle - mountPath: /util name: util nodeSelector: kubernetes.io/os: linux restartPolicy: Never schedulerName: default-scheduler securityContext: runAsNonRoot: true runAsUser: 1001 seccompProfile: type: RuntimeDefault terminationGracePeriodSeconds: 30 tolerations: - key: kubernetes.io/arch operator: Equal value: amd64 - key: kubernetes.io/arch operator: Equal value: arm64 - key: kubernetes.io/arch operator: Equal value: ppc64le - key: kubernetes.io/arch operator: Equal value: s390x volumes: - emptyDir: {} name: bundle - emptyDir: {} name: util status: conditions: - lastProbeTime: "2024-03-30T03:20:00Z" lastTransitionTime: "2024-03-30T03:20:00Z" message: Job has reached the specified backoff limit reason: BackoffLimitExceeded status: "True" type: Failed failed: 4 ready: 0 startTime: "2024-03-30T03:18:45Z" terminating: 0 uncountedTerminatedPods: {} [root@openfuyao-0004 bundle]# ``` ### memcached-operator-catalog-configmap ``` [root@openfuyao-0004 operatorframework]# kubectl get configmap memcached-operator-catalog-configmap-partition-1 -n memcached-operator -oyaml apiVersion: v1 binaryData: extraFBC: H4sIAAAAAAAA/6RWTW/jNhC961cMdC4ZOUmLgqem3UsO6RZI0UOLohiTY5triiRISl53u/+9EPWxkmOlKdanETnvvZkhZ2hFO2xM+umA1pIR4DwFTC6wqI4sNJZtG6sMFRZrElBTLVEeSLHRr4jyQDUKcKbmHuUR91QwxgqyKWiKomCwhuVtxSu+GbjXlAfS/xSXfQpZXNcZoZw8UuDa3Zww1sq5EG9esgxCot3wilermY7RvhaPD52ZhrzT2VMf2749FgAtmoZEAQCwD67xAjKeT8HlraO2SsDTSJ7XWgpROyug3aDxB9ws2MeyLxSGxZ/Xzm1B22c255Sx5TUlVJhwSYzWuoRJOxv7BQA0NaOPWHtDUcA/bFgG+GOyAD7NbIASvf6tly8FlBeFuBnzLL9ZorridP5TeS4dxphLcSEIUBrckolXdnI4nh+bLQVLiWJ3ZWQgTKTY9twJvqzghfIKi7YxoZW05Ii5Vm9jqNHiforj2MTkav33G8HdZV5Ivw3mMSTmdiuJXzB8vqQsX6iOCRev4MroSZYCbGPMbOPzZP85WBI9brXRuc3gR4xawmNX5gk3HN1DElDeVrf3rLpjd9Wv1fei+lbcV7+PcYwZRT5au4A1nVw4dlXYNtooChejqd3wuztevY3CB/eBZPrL4Nk1ScDe5UoPzJ1He993ldfPFFot6R3ttNV9f8GnPn0Z1DuKMmi/6Dt3sqTGDwbqi8tsgICOkA4Ez3lWws6F/DmdTYSHXx6nIisdvcFzPzaWQwhWhlP3uxiakV+bbHB1kmXVeeQrw2oR2YqP7q/Bk1M0FIlBbLx3IZESsEMTaQilH3XvT7YjjB4lvcX/Wdu9of8FeWpM0q8gUmiWgAdjJvfhSaDzyQU1pbSSvdH2OPnY5QnC+7knQBOMgENKPoqbK28iV65GbbNzZyTUlsJETjVqI+ADtpiP94fN7XdcurqY34Zpd2BJTdDpLCCfe/9GBdfqrsMWuJM2KhaBTNfDj91Lnl/Tr3nTR+qy/EK0l5ll1o7ZZmGLkvngPp5FW/HNPd9chb+mfkV2/k+lj+3fAAAA///Ey0YqegkAAA== kind: ConfigMap metadata: annotations: olm.contentEncoding: gzip+base64 creationTimestamp: "2024-03-30T08:12:39Z" name: memcached-operator-catalog-configmap-partition-1 namespace: memcached-operator ownerReferences: - apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource name: memcached-operator-catalog uid: eda914c3-1b3e-4ae4-9e66-1f1c3982f365 resourceVersion: "11827444" uid: 6001dfbe-7c03-4fd5-8b9a-f8cb57475fea [root@openfuyao-0004 operatorframework]# ``` #### configmap data ``` echo H4sIAAAAAAAA/6RWTW/jNhC961cMdC4ZOUmLgqem3UsO6RZI0UOLohiTY5triiRISl53u/+9EPWxkmOlKdanETnvvZkhZ2hFO2xM+umA1pIR4DwFTC6wqI4sNJZtG6sMFRZrElBTLVEeSLHRr4jyQDUKcKbmHuUR91QwxgqyKWiKomCwhuVtxSu+GbjXlAfS/xSXfQpZXNcZoZw8UuDa3Zww1sq5EG9esgxCot3wilermY7RvhaPD52ZhrzT2VMf2749FgAtmoZEAQCwD67xAjKeT8HlraO2SsDTSJ7XWgpROyug3aDxB9ws2MeyLxSGxZ/Xzm1B22c255Sx5TUlVJhwSYzWuoRJOxv7BQA0NaOPWHtDUcA/bFgG+GOyAD7NbIASvf6tly8FlBeFuBnzLL9ZorridP5TeS4dxphLcSEIUBrckolXdnI4nh+bLQVLiWJ3ZWQgTKTY9twJvqzghfIKi7YxoZW05Ii5Vm9jqNHiforj2MTkav33G8HdZV5Ivw3mMSTmdiuJXzB8vqQsX6iOCRev4MroSZYCbGPMbOPzZP85WBI9brXRuc3gR4xawmNX5gk3HN1DElDeVrf3rLpjd9Wv1fei+lbcV7+PcYwZRT5au4A1nVw4dlXYNtooChejqd3wuztevY3CB/eBZPrL4Nk1ScDe5UoPzJ1He993ldfPFFot6R3ttNV9f8GnPn0Z1DuKMmi/6Dt3sqTGDwbqi8tsgICOkA4Ez3lWws6F/DmdTYSHXx6nIisdvcFzPzaWQwhWhlP3uxiakV+bbHB1kmXVeeQrw2oR2YqP7q/Bk1M0FIlBbLx3IZESsEMTaQilH3XvT7YjjB4lvcX/Wdu9of8FeWpM0q8gUmiWgAdjJvfhSaDzyQU1pbSSvdH2OPnY5QnC+7knQBOMgENKPoqbK28iV65GbbNzZyTUlsJETjVqI+ADtpiP94fN7XdcurqY34Zpd2BJTdDpLCCfe/9GBdfqrsMWuJM2KhaBTNfDj91Lnl/Tr3nTR+qy/EK0l5ll1o7ZZmGLkvngPp5FW/HNPd9chb+mfkV2/k+lj+3fAAAA///Ey0YqegkAAA== | base64 -d | gzip -d ``` ``` defaultChannel: operator-sdk-run-bundle name: memcached-operator schema: olm.package --- entries: - name: memcached-operator.v0.0.1 name: operator-sdk-run-bundle package: memcached-operator schema: olm.channel --- image: docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 name: memcached-operator.v0.0.1 package: memcached-operator properties: - type: olm.gvk value: group: cache.wasmdoors kind: Memcached version: v1alpha1 - type: olm.package value: packageName: memcached-operator version: 0.0.1 - type: olm.csv.metadata value: annotations: alm-examples: |- [ { "apiVersion": "cache.wasmdoors/v1alpha1", "kind": "Memcached", "metadata": { "labels": { "app.kubernetes.io/created-by": "memcached-operator", "app.kubernetes.io/instance": "memcached-sample", "app.kubernetes.io/managed-by": "kustomize", "app.kubernetes.io/name": "memcached", "app.kubernetes.io/part-of": "memcached-operator" }, "name": "memcached-sample" }, "spec": null } ] capabilities: Basic Install createdAt: "2024-03-30T08:05:40Z" operators.operatorframework.io/builder: operator-sdk-v1.33.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 apiServiceDefinitions: {} crdDescriptions: owned: - description: Memcached is the Schema for the memcacheds API displayName: Memcached kind: Memcached name: memcacheds.cache.wasmdoors version: v1alpha1 description: memcached-operator displayName: memcached-operator installModes: - supported: false type: OwnNamespace - supported: false type: SingleNamespace - supported: false type: MultiNamespace - supported: true type: AllNamespaces keywords: - memcached-operator links: - name: Memcached Operator url: https://memcached-operator.domain maintainers: - email: javadoors@126.com name: javadoors maturity: alpha provider: name: wilds relatedImages: - image: docker.io/wasmdoors/memcached-operator-bundle:v1.0.0 name: "" - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.14.1 name: "" - image: wasmdoors/memcached-operator:v1.0.0 name: "" schema: olm.bundle ``` ## uninstall ``` [root@openfuyao-0004 memcached-operator]# operator-sdk cleanup -n memcached-operator memcached-operator INFO[0000] subscription "memcached-operator-v0-0-1-sub" deleted INFO[0000] catalogsource "memcached-operator-catalog" deleted INFO[0000] operatorgroup "operator-sdk-og" deleted INFO[0000] Operator "memcached-operator" uninstalled ``` # memcached-operator // TODO(user): Add simple overview of use/purpose ## Description // TODO(user): An in-depth paragraph about your project and overview of use ## Getting Started You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster. **Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). ### Running on the cluster 1. Install Instances of Custom Resources: ```sh kubectl apply -f config/samples/ ``` 2. Build and push your image to the location specified by `IMG`: ```sh make docker-build docker-push IMG=/memcached-operator:tag ``` 3. Deploy the controller to the cluster with the image specified by `IMG`: ```sh make deploy IMG=/memcached-operator:tag ``` ### Uninstall CRDs To delete the CRDs from the cluster: ```sh make uninstall ``` ### Undeploy controller UnDeploy the controller from the cluster: ```sh make undeploy ``` ## Contributing // TODO(user): Add detailed information on how you would like others to contribute to this project ### How it works This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/). It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/), which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. ### Test It Out 1. Install the CRDs into the cluster: ```sh make install ``` 2. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running): ```sh make run ``` **NOTE:** You can also run this in one step by running: `make install run` ### Modifying the API definitions If you are editing the API definitions, generate the manifests such as CRs or CRDs using: ```sh make manifests ``` **NOTE:** Run `make --help` for more information on all potential `make` targets More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html) ## License Copyright 2024. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.