From bb65396df6f6a0bff83672911977cc75c238cadd Mon Sep 17 00:00:00 2001 From: wjluo <32973778+wjluo@users.noreply.github.com> Date: Sun, 8 May 2022 14:20:59 +0800 Subject: [PATCH] K8s yaml (#254) * wjluo add k8s-yaml, 20220509 * Update README.md Co-authored-by: ccoe --- playground/deploy-k8s/README.md | 35 +++++++++++ .../guacd-claim0-persistentvolumeclaim.yaml | 15 +++++ playground/deploy-k8s/guacd-deployment.yaml | 39 ++++++++++++ playground/deploy-k8s/guacd-service.yaml | 19 ++++++ .../mysql-claim0-persistentvolumeclaim.yaml | 15 +++++ playground/deploy-k8s/mysql-deployment.yaml | 48 ++++++++++++++ playground/deploy-k8s/mysql-service.yaml | 19 ++++++ ...terminal-claim0-persistentvolumeclaim.yaml | 15 +++++ ...terminal-claim1-persistentvolumeclaim.yaml | 15 +++++ .../deploy-k8s/next-terminal-deployment.yaml | 63 +++++++++++++++++++ .../deploy-k8s/next-terminal-service.yaml | 19 ++++++ playground/deploy-k8s/start.sh | 10 +++ playground/deploy-k8s/stop.sh | 11 ++++ 13 files changed, 323 insertions(+) create mode 100644 playground/deploy-k8s/README.md create mode 100644 playground/deploy-k8s/guacd-claim0-persistentvolumeclaim.yaml create mode 100644 playground/deploy-k8s/guacd-deployment.yaml create mode 100644 playground/deploy-k8s/guacd-service.yaml create mode 100644 playground/deploy-k8s/mysql-claim0-persistentvolumeclaim.yaml create mode 100644 playground/deploy-k8s/mysql-deployment.yaml create mode 100644 playground/deploy-k8s/mysql-service.yaml create mode 100644 playground/deploy-k8s/next-terminal-claim0-persistentvolumeclaim.yaml create mode 100644 playground/deploy-k8s/next-terminal-claim1-persistentvolumeclaim.yaml create mode 100644 playground/deploy-k8s/next-terminal-deployment.yaml create mode 100644 playground/deploy-k8s/next-terminal-service.yaml create mode 100644 playground/deploy-k8s/start.sh create mode 100644 playground/deploy-k8s/stop.sh diff --git a/playground/deploy-k8s/README.md b/playground/deploy-k8s/README.md new file mode 100644 index 0000000..03bfd28 --- /dev/null +++ b/playground/deploy-k8s/README.md @@ -0,0 +1,35 @@ +# K8S部署指南 + +## 环境准备 + +1、准备一个标准的Kubernetes集群。 +2、创建一个storageClassName,譬如 cbs-next-terminal +3、创建一个命名空间 next-terminal + +## 启动next-terminal +1、根据需要修改相关参数,譬如PV卷的大小,端口。 +2、执行start.sh,如下所示: +- kubectl apply -f mysql-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl apply -f mysql-deployment.yaml -n next-terminal +- kubectl apply -f mysql-service.yaml -n next-terminal +- kubectl apply -f guacd-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl apply -f guacd-deployment.yaml -n next-terminal +- kubectl apply -f guacd-service.yaml -n next-terminal +- kubectl apply -f next-terminal-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl apply -f next-terminal-claim1-persistentvolumeclaim.yaml -n next-terminal +- kubectl apply -f next-terminal-deployment.yaml -n next-terminal +- kubectl apply -f next-terminal-service.yaml -n next-terminal +3、在Kubernetes集群中查询service,可以增加ingress配置,进行访问。 + +## 销毁next-terminal +1、执行stop.sh,如下所示: +- kubectl delete -f mysql-service.yaml -n next-terminal +- kubectl delete -f mysql-deployment.yaml -n next-terminal +- kubectl delete -f mysql-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl delete -f guacd-service.yaml -n next-terminal +- kubectl delete -f guacd-deployment.yaml -n next-terminal +- kubectl delete -f guacd-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl delete -f next-terminal-service.yaml -n next-terminal +- kubectl delete -f next-terminal-deployment.yaml -n next-terminal +- kubectl delete -f next-terminal-claim0-persistentvolumeclaim.yaml -n next-terminal +- kubectl delete -f next-terminal-claim1-persistentvolumeclaim.yaml -n next-terminal diff --git a/playground/deploy-k8s/guacd-claim0-persistentvolumeclaim.yaml b/playground/deploy-k8s/guacd-claim0-persistentvolumeclaim.yaml new file mode 100644 index 0000000..9d781ae --- /dev/null +++ b/playground/deploy-k8s/guacd-claim0-persistentvolumeclaim.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: guacd-claim0 + name: guacd-claim0 +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: cbs-next-terminal +status: {} diff --git a/playground/deploy-k8s/guacd-deployment.yaml b/playground/deploy-k8s/guacd-deployment.yaml new file mode 100644 index 0000000..952e0e5 --- /dev/null +++ b/playground/deploy-k8s/guacd-deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: guacd + name: guacd +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: guacd + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: guacd + spec: + containers: + - image: dushixiang/guacd:latest + name: guacd + resources: {} + volumeMounts: + - mountPath: /usr/local/next-terminal/data + name: guacd-claim0 + restartPolicy: Always + volumes: + - name: guacd-claim0 + persistentVolumeClaim: + claimName: guacd-claim0 +status: {} diff --git a/playground/deploy-k8s/guacd-service.yaml b/playground/deploy-k8s/guacd-service.yaml new file mode 100644 index 0000000..d7540a3 --- /dev/null +++ b/playground/deploy-k8s/guacd-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: guacd + name: guacd +spec: + ports: + - name: "4822" + port: 4822 + targetPort: 4822 + selector: + io.kompose.service: guacd +status: + loadBalancer: {} diff --git a/playground/deploy-k8s/mysql-claim0-persistentvolumeclaim.yaml b/playground/deploy-k8s/mysql-claim0-persistentvolumeclaim.yaml new file mode 100644 index 0000000..41c05f6 --- /dev/null +++ b/playground/deploy-k8s/mysql-claim0-persistentvolumeclaim.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: mysql-claim0 + name: mysql-claim0 +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: cbs-next-terminal +status: {} diff --git a/playground/deploy-k8s/mysql-deployment.yaml b/playground/deploy-k8s/mysql-deployment.yaml new file mode 100644 index 0000000..33f5b23 --- /dev/null +++ b/playground/deploy-k8s/mysql-deployment.yaml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: mysql + name: mysql +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: mysql + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: mysql + spec: + containers: + - env: + - name: MYSQL_DATABASE + value: next-terminal + - name: MYSQL_PASSWORD + value: next-terminal + - name: MYSQL_ROOT_PASSWORD + value: next-terminal + - name: MYSQL_USER + value: next-terminal + image: mysql:8.0 + name: mysql + resources: {} + volumeMounts: + - mountPath: /var/lib/mysql + name: mysql-claim0 + restartPolicy: Always + volumes: + - name: mysql-claim0 + persistentVolumeClaim: + claimName: mysql-claim0 +status: {} diff --git a/playground/deploy-k8s/mysql-service.yaml b/playground/deploy-k8s/mysql-service.yaml new file mode 100644 index 0000000..f92e144 --- /dev/null +++ b/playground/deploy-k8s/mysql-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: mysql + name: mysql +spec: + ports: + - name: "3306" + port: 3306 + targetPort: 3306 + selector: + io.kompose.service: mysql +status: + loadBalancer: {} diff --git a/playground/deploy-k8s/next-terminal-claim0-persistentvolumeclaim.yaml b/playground/deploy-k8s/next-terminal-claim0-persistentvolumeclaim.yaml new file mode 100644 index 0000000..fe53182 --- /dev/null +++ b/playground/deploy-k8s/next-terminal-claim0-persistentvolumeclaim.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: next-terminal-claim0 + name: next-terminal-claim0 +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: cbs-next-terminal +status: {} diff --git a/playground/deploy-k8s/next-terminal-claim1-persistentvolumeclaim.yaml b/playground/deploy-k8s/next-terminal-claim1-persistentvolumeclaim.yaml new file mode 100644 index 0000000..e1c71bd --- /dev/null +++ b/playground/deploy-k8s/next-terminal-claim1-persistentvolumeclaim.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: next-terminal-claim1 + name: next-terminal-claim1 +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: cbs-next-terminal +status: {} diff --git a/playground/deploy-k8s/next-terminal-deployment.yaml b/playground/deploy-k8s/next-terminal-deployment.yaml new file mode 100644 index 0000000..1ebbe02 --- /dev/null +++ b/playground/deploy-k8s/next-terminal-deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: next-terminal + name: next-terminal +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: next-terminal + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: next-terminal + spec: + containers: + - env: + - name: DB + value: mysql + - name: GUACD_HOSTNAME + value: guacd + - name: GUACD_PORT + value: "4822" + - name: MYSQL_DATABASE + value: next-terminal + - name: MYSQL_HOSTNAME + value: mysql + - name: MYSQL_PASSWORD + value: next-terminal + - name: MYSQL_PORT + value: "3306" + - name: MYSQL_USERNAME + value: next-terminal + image: dushixiang/next-terminal:latest + name: next-terminal + ports: + - containerPort: 8088 + resources: {} + volumeMounts: + - mountPath: /etc + name: next-terminal-claim0 + - mountPath: /usr/local/next-terminal/data + name: next-terminal-claim1 + restartPolicy: Always + volumes: + - name: next-terminal-claim0 + persistentVolumeClaim: + claimName: next-terminal-claim0 + - name: next-terminal-claim1 + persistentVolumeClaim: + claimName: next-terminal-claim1 +status: {} diff --git a/playground/deploy-k8s/next-terminal-service.yaml b/playground/deploy-k8s/next-terminal-service.yaml new file mode 100644 index 0000000..e670366 --- /dev/null +++ b/playground/deploy-k8s/next-terminal-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: next-terminal + name: next-terminal +spec: + ports: + - name: "8088" + port: 8088 + targetPort: 8088 + selector: + io.kompose.service: next-terminal +status: + loadBalancer: {} diff --git a/playground/deploy-k8s/start.sh b/playground/deploy-k8s/start.sh new file mode 100644 index 0000000..542107b --- /dev/null +++ b/playground/deploy-k8s/start.sh @@ -0,0 +1,10 @@ +kubectl apply -f mysql-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl apply -f mysql-deployment.yaml -n next-terminal +kubectl apply -f mysql-service.yaml -n next-terminal +kubectl apply -f guacd-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl apply -f guacd-deployment.yaml -n next-terminal +kubectl apply -f guacd-service.yaml -n next-terminal +kubectl apply -f next-terminal-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl apply -f next-terminal-claim1-persistentvolumeclaim.yaml -n next-terminal +kubectl apply -f next-terminal-deployment.yaml -n next-terminal +kubectl apply -f next-terminal-service.yaml -n next-terminal diff --git a/playground/deploy-k8s/stop.sh b/playground/deploy-k8s/stop.sh new file mode 100644 index 0000000..ebb5984 --- /dev/null +++ b/playground/deploy-k8s/stop.sh @@ -0,0 +1,11 @@ +kubectl delete -f mysql-service.yaml -n next-terminal +kubectl delete -f mysql-deployment.yaml -n next-terminal +kubectl delete -f mysql-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl delete -f guacd-service.yaml -n next-terminal +kubectl delete -f guacd-deployment.yaml -n next-terminal +kubectl delete -f guacd-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl delete -f next-terminal-service.yaml -n next-terminal +kubectl delete -f next-terminal-deployment.yaml -n next-terminal +kubectl delete -f next-terminal-claim0-persistentvolumeclaim.yaml -n next-terminal +kubectl delete -f next-terminal-claim1-persistentvolumeclaim.yaml -n next-terminal +