|
| 1 | +# Memcached Helm Operator |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This Memcached operator is a simple example operator based in Helm built with the [Operator SDK][operator_sdk]. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- [docker][docker_tool] version 17.03+ |
| 10 | +- [kubectl][kubectl_tool] v1.11.3+ |
| 11 | +- [operator_sdk][operator_install] |
| 12 | +- Access to a Kubernetes v1.11.3+ cluster |
| 13 | + |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +### Cloning the repository |
| 17 | + |
| 18 | +Checkout this Memcached Operator repository |
| 19 | + |
| 20 | +``` |
| 21 | +$ mkdir operator-framework |
| 22 | +$ cd operator-framework |
| 23 | +$ git clone https://github.com/operator-framework/operator-sdk-samples.git |
| 24 | +$ cd operator-sdk-samples/helm/memcached-operator |
| 25 | +``` |
| 26 | + |
| 27 | +### Building the operator |
| 28 | + |
| 29 | +Build the Memcached operator image and push it to a public registry, such as quay.io: |
| 30 | + |
| 31 | +``` |
| 32 | +$ export IMAGE=quay.io/example-inc/memcached-operator:v0.0.1 |
| 33 | +$ operator-sdk build $IMAGE |
| 34 | +$ docker push $IMAGE |
| 35 | +``` |
| 36 | + |
| 37 | +**NOTE** The `quay.io/example-inc/memcached-operator` is an example. You should build and push the image for your repository. |
| 38 | + |
| 39 | +### Using the image |
| 40 | + |
| 41 | +``` |
| 42 | +# Update the operator manifest to use the built image name (if you are performing these steps on OSX, see note below) |
| 43 | +$ sed -i 's|REPLACE_IMAGE|quay.io/example-inc/memcached-operator|g' deploy/operator.yaml |
| 44 | +# On OSX use: |
| 45 | +$ sed -i "" 's|REPLACE_IMAGE|quay.io/example-inc/memcached-operator|g' deploy/operator.yaml |
| 46 | +``` |
| 47 | + |
| 48 | +### Installing |
| 49 | + |
| 50 | +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. |
| 51 | + |
| 52 | +Following the expected result. |
| 53 | + |
| 54 | +```shell |
| 55 | +$ kubectl get all -n helm-memcached |
| 56 | +NAME READY STATUS RESTARTS AGE |
| 57 | +pod/example-memcached-84dc867dc-b28wc 1/1 Running 0 7s |
| 58 | +pod/example-memcached-84dc867dc-vrxd8 1/1 Running 0 7s |
| 59 | +pod/example-memcached-84dc867dc-vvb29 1/1 Running 0 7s |
| 60 | +pod/memcached-operator-5b45959c8b-sx9x4 1/1 Running 0 13s |
| 61 | + |
| 62 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 63 | +service/example-memcached ClusterIP 10.107.76.22 <none> 80/TCP 7s |
| 64 | +service/memcached-operator-metrics ClusterIP 10.99.126.244 <none> 8686/TCP,8383/TCP 7s |
| 65 | + |
| 66 | +NAME READY UP-TO-DATE AVAILABLE AGE |
| 67 | +deployment.apps/example-memcached 3/3 3 3 7s |
| 68 | +deployment.apps/memcached-operator 1/1 1 1 13s |
| 69 | + |
| 70 | +NAME DESIRED CURRENT READY AGE |
| 71 | +replicaset.apps/example-memcached-84dc867dc 3 3 3 7s |
| 72 | +replicaset.apps/memcached-operator-5b45959c8b 1 1 1 13s |
| 73 | +``` |
| 74 | + |
| 75 | +### Uninstalling |
| 76 | + |
| 77 | +To uninstall all that was performed in the above step run `make uninstall`. |
| 78 | + |
| 79 | +### Troubleshooting |
| 80 | + |
| 81 | +Run the following command to check the operator logs. |
| 82 | + |
| 83 | +```shell |
| 84 | +kubectl logs deployment.apps/memcached-operator -n helm-memcached |
| 85 | +``` |
| 86 | + |
| 87 | +**NOTE** To have further information about how to develop Helm operators with [Operator-SDK][operator_sdk] check the [Helm User Guide for Operator-SDK][helm_guide] |
| 88 | + |
| 89 | +### Extras |
| 90 | + |
| 91 | +Mote that this project was created by using the following command which means that it is using the [stable/memcached][stable/memcached] |
| 92 | + |
| 93 | +```shell |
| 94 | +operator-sdk new memcached-operator --api-version=cache.example.com/v1alpha1 --kind=Memcached --type=helm --helm-chart=stable/memcached |
| 95 | +``` |
| 96 | + |
| 97 | +[kubectl_tool]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
| 98 | +[docker_tool]: https://docs.docker.com/install/ |
| 99 | +[operator_sdk]: https://github.com/operator-framework/operator-sdk |
| 100 | +[operator_install]: https://github.com/operator-framework/operator-sdk/blob/master/doc/user/install-operator-sdk.md |
| 101 | +[helm_guide]: https://github.com/operator-framework/operator-sdk/blob/master/doc/helm/user-guide.md |
| 102 | +[stable/memcached]: https://github.com/helm/charts/tree/master/stable/memcached |
0 commit comments