This repository was archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Upgrade helm sample to 0.11.0 version of SDK #78
Merged
camilamacedo86
merged 5 commits into
operator-framework:master
from
camilamacedo86:updat-helm
Oct 24, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ddb2481
init project by using --helm-chart=stable/memcached
camilamacedo86 7df13a2
add make file and readme
camilamacedo86 b889ac0
fix replicas inifinity
camilamacedo86 30b4c60
fix role permission
camilamacedo86 2c9a675
review changes
camilamacedo86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/* | ||
helm/memcached-operator/.idea/* | ||
ansible/memcached-operator/.idea/* |
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,37 @@ | ||
.DEFAULT_GOAL:=help | ||
SHELL:=/bin/bash | ||
NAMESPACE=helm-memcached | ||
|
||
##@ Application | ||
|
||
install: ## Install all resources (CR/CRD's, RBCA and Operator) | ||
@echo ....... Creating namespace ....... | ||
- kubectl create namespace ${NAMESPACE} | ||
@echo ....... Applying CRDS and Operator ....... | ||
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_crd.yaml -n ${NAMESPACE} | ||
@echo ....... Applying Rules and Service Account ....... | ||
- kubectl apply -f deploy/role.yaml -n ${NAMESPACE} | ||
- kubectl apply -f deploy/role_binding.yaml -n ${NAMESPACE} | ||
- kubectl apply -f deploy/service_account.yaml -n ${NAMESPACE} | ||
@echo ....... Applying Operator ....... | ||
- kubectl apply -f deploy/operator.yaml -n ${NAMESPACE} | ||
@echo ....... Creating the Memcached Instance ....... | ||
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml -n ${NAMESPACE} | ||
|
||
uninstall: ## Uninstall all that all performed in the $ make install | ||
@echo ....... Uninstalling ....... | ||
@echo ....... Deleting CR and CRD....... | ||
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml -n ${NAMESPACE} | ||
- kubectl delete -f deploy/crds/cache.example.com_v1alpha1_memcached_crd.yaml -n ${NAMESPACE} | ||
@echo ....... Deleting Rules and Service Account ....... | ||
- kubectl delete -f deploy/role.yaml -n ${NAMESPACE} | ||
- kubectl delete -f deploy/role_binding.yaml -n ${NAMESPACE} | ||
- kubectl delete -f deploy/service_account.yaml -n ${NAMESPACE} | ||
@echo ....... Deleting Operator ....... | ||
- kubectl delete -f deploy/operator.yaml -n ${NAMESPACE} | ||
@echo ....... Deleting namespace ${NAMESPACE}....... | ||
- kubectl delete namespace ${NAMESPACE} | ||
|
||
.PHONY: help | ||
help: ## Display this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
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,107 @@ | ||
# Memcached Helm Operator | ||
|
||
## Overview | ||
|
||
This Memcached operator is a simple example of the Operator SDK Helm-based operator. It is based on the [`stable/memcached` chart][stable/memcached] . | ||
|
||
## Prerequisites | ||
|
||
- [docker][docker_tool] version 17.03+ | ||
- [kubectl][kubectl_tool] v1.12+ | ||
- [operator SDK][operator_install] | ||
- Access to a Kubernetes v1.14.5+ cluster | ||
|
||
## Getting Started | ||
|
||
### Cloning the repository | ||
|
||
Checkout this Memcached operator repository | ||
|
||
``` | ||
$ mkdir operator-framework | ||
$ cd operator-framework | ||
$ git clone https://github.com/operator-framework/operator-sdk-samples.git | ||
$ cd operator-sdk-samples/helm/memcached-operator | ||
``` | ||
|
||
### Building the operator | ||
|
||
Build the Memcached operator image and push it to a public registry, such as quay.io: | ||
|
||
``` | ||
$ export IMAGE=quay.io/example-inc/memcached-operator:v0.0.1 | ||
$ operator-sdk build $IMAGE | ||
$ docker push $IMAGE | ||
``` | ||
|
||
**NOTE** The `quay.io/example-inc/memcached-operator` is an example. You should build and push the image for your repository. | ||
|
||
### Using the image | ||
|
||
Update the operator manifest to use the built image name (if you are performing these steps on OSX, see note below) | ||
|
||
``` | ||
$ sed -i 's|REPLACE_IMAGE|quay.io/example-inc/memcached-operator|g' deploy/operator.yaml | ||
``` | ||
|
||
**Note** | ||
If you are performing these steps on OSX, use the following `sed` command instead: | ||
``` | ||
$ sed -i "" 's|REPLACE_IMAGE|quay.io/example-inc/memcached-operator|g' deploy/operator.yaml | ||
``` | ||
|
||
### Installing | ||
|
||
Run `make install` to install the operator. Check that the operator is running in the cluster, also check that the example Memcached service was deployed. | ||
|
||
Run the following command to verify that the installation was successful: | ||
|
||
```shell | ||
$ kubectl get all -n helm-memcached -o wide | ||
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES | ||
pod/example-memcached-0 1/1 Running 0 37s 172.17.0.5 minikube <none> <none> | ||
pod/example-memcached-1 1/1 Running 0 19s 172.17.0.6 minikube <none> <none> | ||
pod/example-memcached-2 1/1 Running 0 12s 172.17.0.7 minikube <none> <none> | ||
pod/memcached-operator-55d98c7cf8-x6x9p 1/1 Running 0 52s 172.17.0.4 minikube <none> <none> | ||
|
||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR | ||
service/example-memcached ClusterIP None <none> 11211/TCP 37s app=example-memcached | ||
service/memcached-operator-metrics ClusterIP 10.96.212.206 <none> 8686/TCP,8383/TCP 38s name=memcached-operator | ||
|
||
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR | ||
deployment.apps/memcached-operator 1/1 1 1 52s memcached-operator cmacedo/memcached-operator:test name=memcached-operator | ||
|
||
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR | ||
replicaset.apps/memcached-operator-55d98c7cf8 1 1 1 52s memcached-operator cmacedo/memcached-operator:test name=memcached-operator,pod-template-hash=55d98c7cf8 | ||
|
||
NAME READY AGE CONTAINERS IMAGES | ||
statefulset.apps/example-memcached 3/3 37s example-memcached memcached:1.5.12-alpine | ||
``` | ||
|
||
### Uninstalling | ||
|
||
Run `make uninstall` to uninstall all that was performed in the above step. | ||
|
||
### Troubleshooting | ||
|
||
Run the following command to check the operator logs. | ||
|
||
```shell | ||
kubectl logs deployment.apps/memcached-operator -n helm-memcached | ||
``` | ||
|
||
**NOTE** For further information about how to develop Helm operators with Operator SDK, read the [Helm User Guide for Operator SDK][helm_guide] | ||
|
||
### Extras | ||
|
||
This project was created by using the following command, which means that it is using the official [stable/memcached][stable/memcached] helm chart. | ||
|
||
```shell | ||
operator-sdk new memcached-operator --api-version=cache.example.com/v1alpha1 --kind=Memcached --type=helm --helm-chart=stable/memcached | ||
``` | ||
|
||
[kubectl_tool]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ | ||
[docker_tool]: https://docs.docker.com/install/ | ||
[operator_install]: https://github.com/operator-framework/operator-sdk/blob/master/doc/user/install-operator-sdk.md | ||
[helm_guide]: https://github.com/operator-framework/operator-sdk/blob/master/doc/helm/user-guide.md | ||
[stable/memcached]: https://github.com/helm/charts/tree/master/stable/memcached |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM quay.io/operator-framework/helm-operator:v0.5.0 | ||
FROM quay.io/operator-framework/helm-operator:v0.11.0 | ||
|
||
COPY helm-charts/ ${HOME}/helm-charts/ | ||
COPY watches.yaml ${HOME}/watches.yaml | ||
COPY helm-charts/ ${HOME}/helm-charts/ |
116 changes: 116 additions & 0 deletions
116
helm/memcached-operator/deploy/crds/cache.example.com_v1alpha1_memcached_cr.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,116 @@ | ||
apiVersion: cache.example.com/v1alpha1 | ||
kind: Memcached | ||
metadata: | ||
name: example-memcached | ||
spec: | ||
# Default values copied from <project_dir>/helm-charts/memcached/values.yaml | ||
|
||
## Memcached image and tag | ||
## ref: https://hub.docker.com/r/library/memcached/tags/ | ||
## | ||
image: memcached:1.5.12-alpine | ||
|
||
## Specify a imagePullPolicy | ||
## 'Always' if imageTag is 'latest', else set to 'IfNotPresent' | ||
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images | ||
## | ||
# imagePullPolicy: | ||
# | ||
|
||
## Replica count | ||
replicaCount: 3 | ||
|
||
## Pod disruption budget minAvailable count | ||
## Ensure this value is lower than replicaCount in order to allow a worker | ||
## node to drain successfully | ||
pdbMinAvailable: 2 | ||
|
||
## Select AntiAffinity as either hard or soft, default is hard | ||
AntiAffinity: "soft" | ||
|
||
memcached: | ||
## Various values that get set as command-line flags. | ||
## ref: https://github.com/memcached/memcached/wiki/ConfiguringServer#commandline-arguments | ||
## | ||
maxItemMemory: 64 | ||
verbosity: v | ||
extendedOptions: modern | ||
|
||
## Additional command line arguments to pass to memcached | ||
## E.g. to specify a maximum value size | ||
## extraArgs: | ||
## - -I 2m | ||
extraArgs: [] | ||
|
||
## Define various attributes of the service | ||
serviceAnnotations: {} | ||
# prometheus.io/scrape: "true" | ||
|
||
## StatefulSet or Deployment | ||
kind: StatefulSet | ||
|
||
## Update Strategy for the StatefulSet or Deployment | ||
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies | ||
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment | ||
updateStrategy: | ||
type: RollingUpdate | ||
|
||
## Configure resource requests and limits | ||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/ | ||
## | ||
resources: | ||
requests: | ||
memory: 64Mi | ||
cpu: 50m | ||
|
||
## Key:value pair for assigning pod to specific sets of nodes | ||
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | ||
nodeSelector: {} | ||
|
||
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ | ||
tolerations: {} | ||
|
||
## Advanced scheduling controls | ||
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | ||
affinity: {} | ||
|
||
## Memcached pod Security Context | ||
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ | ||
securityContext: | ||
enabled: true | ||
fsGroup: 1001 | ||
runAsUser: 1001 | ||
|
||
metrics: | ||
## Expose memcached metrics in Prometheus format | ||
enabled: false | ||
|
||
## Memcached exporter image and tag | ||
image: quay.io/prometheus/memcached-exporter:v0.4.1 | ||
|
||
## Specify a imagePullPolicy | ||
## 'Always' if imageTag is 'latest', else set to 'IfNotPresent' | ||
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images | ||
## | ||
# imagePullPolicy: IfNotPresent | ||
|
||
## Configure resource requests and limits | ||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/ | ||
## | ||
resources: {} | ||
|
||
extraContainers: | | ||
|
||
extraVolumes: | | ||
|
||
## Custom metadata labels to be applied to statefulset and pods | ||
# podLabels: | ||
# foo: "bar" | ||
# bar: "foo" | ||
|
||
# To be added to the server pod(s) | ||
podAnnotations: {} | ||
|
||
## Set pod priority class | ||
# priorityClassName: "" | ||
|
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
7 changes: 0 additions & 7 deletions
7
helm/memcached-operator/deploy/crds/cache_v1alpha1_memcached_cr.yaml
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.