From 91839f852544dcea73a661bdf2ed22fdd560ffa6 Mon Sep 17 00:00:00 2001 From: timlackhan <727781157@qq.com> Date: Wed, 4 Sep 2019 17:23:19 +0800 Subject: [PATCH] =?UTF-8?q?Add=E2=80=9Cmemcached=20deploy=20with=20k8s?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- memcached/README.md | 38 ++++++++++++++++++++++++ memcached/memcached-deployment-conf.yaml | 36 ++++++++++++++++++++++ memcached/memcached-deployment.yaml | 35 ++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 memcached/memcached-deployment-conf.yaml create mode 100644 memcached/memcached-deployment.yaml diff --git a/memcached/README.md b/memcached/README.md index 5204981..ea39bcb 100644 --- a/memcached/README.md +++ b/memcached/README.md @@ -50,7 +50,45 @@ image](https://hub.docker.com/_/memcached). docker run --network somenetwork --name memcached-server -d clearlinux/memcached ``` + + + + +### Deploy with Kubernetes + +This image can also be deployed on a Kubernetes cluster, such as [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/).The following example YAML files are provided in the repository as reference for Kubernetes deployment: + +- [`memcached-deployment.yaml`](https://github.com/clearlinux/dockerfiles/blob/master/memcached/memcached-deployment.yaml): example using default configuration to create a basic memcached service. + +- [`memcached-deployment-conf.yaml`](https://github.com/clearlinux/dockerfiles/blob/master/memcached/memcached-deployment-conf.yaml): example using your own custom configuration to create a memcached service. + + + +Steps to deploy memcached on a Kubernetes cluster: + +1. If you want to deploy `memcached-deployment.yaml` + + ``` + kubectl create -f memcached-deployment.yaml + ``` + + Or if you want to deploy `memcached-deployment-conf.yaml` + + ``` + kubectl create -f memcached-deployment-conf.yaml + ``` + +2. Install telnet bundle and connect to the service, where 30100 is the port number defined in your service. + + ``` + swupd bundle-add netkit-telnet + telnet 30100 + ``` + + + + ## Build and modify: The Dockerfiles for all Clear Linux* OS based container images are available at diff --git a/memcached/memcached-deployment-conf.yaml b/memcached/memcached-deployment-conf.yaml new file mode 100644 index 0000000..f38512b --- /dev/null +++ b/memcached/memcached-deployment-conf.yaml @@ -0,0 +1,36 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: memcached +spec: + replicas: 1 + revisionHistoryLimit: 2 + template: + metadata: + labels: + run: memcached + spec: + containers: + - name: memcached + image: docker.io/clearlinux/memcached + ports: + - containerPort: 11211 + # -u:USER -p:PORT -c:MAXCONN -m:CACHESIZE + args: ["-u memcached", "-p 11211", "-c 1024", "-m 64"] + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + run: memcached + name: memcached +spec: + type: NodePort + ports: + - port: 11211 + protocol: TCP + targetPort: 11211 + nodePort: 30100 + selector: + run: memcached diff --git a/memcached/memcached-deployment.yaml b/memcached/memcached-deployment.yaml new file mode 100644 index 0000000..2177c6a --- /dev/null +++ b/memcached/memcached-deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: memcached +spec: + replicas: 1 + revisionHistoryLimit: 2 + template: + metadata: + labels: + run: memcached + spec: + containers: + - name: memcached + image: docker.io/clearlinux/memcached + ports: + - containerPort: 11211 + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + run: memcached + name: memcached +spec: + type: NodePort + ports: + - port: 11211 + protocol: TCP + targetPort: 11211 + nodePort: 30100 + selector: + run: memcached +