The Memcached Operator is a Kubernetes operator designed to automate the deployment and management of Memcached instances within a Kubernetes cluster. It leverages a custom resource definition (CRD) to manage the lifecycle of Memcached deployments.
Data flow diagram of a kubernetes memcache operator with nettools
- Automated Deployment: Simplifies the deployment of Memcached instances.
- Scalability: Supports scaling of Memcached deployments.
- Status Monitoring: Provides updates on the status of Memcached custom resources.
- Debugging Support: Each pod includes a debugging container (
nettools
) for network troubleshooting and diagnostics. It use (nicolaka/netshoot
) image for nettools installation.
The operator utilizes a CRD named MemcachedDeployment
. Below is an example configuration:
apiVersion: cache.example.com/v1
kind: MemcachedDeployment
metadata:
name: example-memcached
spec:
size: 3
image: memcached:1.4.36-alpine
The CRD is defined as follows:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: memcacheddeployments.cache.example.com
spec:
group: cache.example.com
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
size:
type: integer
description: "Specifies the number of Memcached instances."
image:
type: string
description: "Defines the Docker image to use for the deployment."
scope: Namespaced
names:
plural: memcacheddeployments
singular: memcacheddeployment
kind: MemcachedDeployment
shortNames:
- mcd
size
: Specifies the number of Memcached instances.image
: Defines the Docker image to use for the deployment.
- Kubernetes cluster (v1.11.3 or higher)
- kubectl (v1.11.3 or higher)
- Go (v1.22.0 or higher)
- Docker (v17.03 or higher)
-
Clone the repository:
git clone https://github.com/sagoresarker/memcached-operator.git cd memcached-operator
-
Build and push the operator image:
make docker-build docker-push IMG=<your-registry>/memcached-operator:tag
-
Install the CRDs:
make install
-
Deploy the operator:
make deploy IMG=<your-registry>/memcached-operator:tag
-
To create a Memcached deployment, use the following YAML configuration:
apiVersion: cache.example.com/v1 kind: MemcachedDeployment metadata: name: example-memcached spec: size: 3 image: memcached:1.4.36-alpine
-
Apply the custom resource:
kubectl apply -f config/samples/cache_v1_memcacheddeployment.yaml
-
Verify the deployment:
kubectl get memcacheddeployment kubectl get pods
-
Local Development:
make run
-
Running Tests:
make test
To build an installer for distribution:
make build-installer IMG=<your-registry>/memcached-operator:tag
This generates an install.yaml
file in the dist
directory, which can be used to install the operator:
kubectl apply -f https://raw.githubusercontent.com/<org>/memcached-operator/<tag or branch>/dist/install.yaml
To remove the operator and CRDs from your cluster:
make uninstall
make undeploy