Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit 7df13a2

Browse files
add make file and readme
1 parent ddb2481 commit 7df13a2

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

helm/memcached-operator/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.DEFAULT_GOAL:=help
2+
SHELL:=/bin/bash
3+
NAMESPACE=helm-memcached
4+
5+
##@ Application
6+
7+
install: ## Install all resources (CR/CRD's, RBCA and Operator)
8+
@echo ....... Creating namespace .......
9+
- kubectl create namespace ${NAMESPACE}
10+
@echo ....... Applying CRDS and Operator .......
11+
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_crd.yaml -n ${NAMESPACE}
12+
@echo ....... Applying Rules and Service Account .......
13+
- kubectl apply -f deploy/role.yaml -n ${NAMESPACE}
14+
- kubectl apply -f deploy/role_binding.yaml -n ${NAMESPACE}
15+
- kubectl apply -f deploy/service_account.yaml -n ${NAMESPACE}
16+
@echo ....... Applying Operator .......
17+
- kubectl apply -f deploy/operator.yaml -n ${NAMESPACE}
18+
@echo ....... Creating the Memcached Instance .......
19+
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml -n ${NAMESPACE}
20+
21+
uninstall: ## Uninstall all that all performed in the $ make install
22+
@echo ....... Uninstalling .......
23+
@echo ....... Deleting CR and CRD.......
24+
- kubectl apply -f deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml -n ${NAMESPACE}
25+
- kubectl delete -f deploy/crds/cache.example.com_v1alpha1_memcached_crd.yaml -n ${NAMESPACE}
26+
@echo ....... Deleting Rules and Service Account .......
27+
- kubectl delete -f deploy/role.yaml -n ${NAMESPACE}
28+
- kubectl delete -f deploy/role_binding.yaml -n ${NAMESPACE}
29+
- kubectl delete -f deploy/service_account.yaml -n ${NAMESPACE}
30+
@echo ....... Deleting Operator .......
31+
- kubectl delete -f deploy/operator.yaml -n ${NAMESPACE}
32+
@echo ....... Deleting namespace ${NAMESPACE}.......
33+
- kubectl delete namespace ${NAMESPACE}
34+
35+
.PHONY: help
36+
help: ## Display this help
37+
@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)

helm/memcached-operator/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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

Comments
 (0)