From 04c3856d34555f27d47eccd9a26aa6dc9a6f2143 Mon Sep 17 00:00:00 2001 From: icechen Date: Tue, 4 Jan 2022 18:33:58 +0800 Subject: [PATCH] update helm --- .../go_api_production_pipeline.go | 142 ++---------------- .../go_api_test_pipeline.go | 142 ++---------------- .../go_service_production_pipeline.go | 115 ++------------ .../go_service_test_pipeline.go | 115 ++------------ 4 files changed, 56 insertions(+), 458 deletions(-) diff --git a/go_handler/go_handler_template/go_api_production_pipeline.go b/go_handler/go_handler_template/go_api_production_pipeline.go index d09fd99..08d403e 100644 --- a/go_handler/go_handler_template/go_api_production_pipeline.go +++ b/go_handler/go_handler_template/go_api_production_pipeline.go @@ -21,135 +21,21 @@ steps: dockerfile: ./{{ .Root }}/Dockerfile - name: deploy - image: sinlead/drone-kubectl + image: bitsbeats/drone-helm3 settings: - kubernetes_server: + kube_api_server: from_secret: kubernetes_server - kubernetes_cert: - from_secret: kubernetes_cert - kubernetes_token: + kube_token: from_secret: kubernetes_token - commands: - - |- -echo ` + ApiProductionDeploy + ` | kubectl apply -f - -# - kubectl wait --for=condition=Ready --timeout=300s -f deploy/deployment.yaml -` - -const ApiProductionDeploy = `kind: Deployment -apiVersion: apps/v1 -metadata: - name: api-{{ .Name }} - namespace: {{ .NameSpace }} - labels: - app: api-{{ .Name }} - annotations: - kubesphere.io/alias-name: {{ .AliasName }} - kubesphere.io/creator: drone -spec: - replicas: 1 - selector: - matchLabels: - app: api-{{ .Name }} - template: - metadata: - creationTimestamp: null - labels: - app: api-{{ .Name }} - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - containers: - - image: 'reg.icechen.cn/{{ .NameSpace }}/api-{{ .Name }}:${DRONE_TAG}' - ports: - - containerPort: {{ .Port }} - protocol: TCP - envFrom: - - configMapRef: - name: service - env: - - name: endpoints - value: 'etcd:2379' - resources: - limits: - cpu: 200m - memory: 1000Mi - requests: - cpu: 50m - memory: 200Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: IfNotPresent - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - serviceAccountName: default - serviceAccount: default - securityContext: {} - imagePullSecrets: - - name: registry-secret - schedulerName: default-scheduler - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 25% - maxSurge: 25% - revisionHistoryLimit: 10 - progressDeadlineSeconds: 600 - ---- - -kind: Service -apiVersion: v1 -metadata: - name: api-{{ .Name }} - namespace: {{ .NameSpace }} - labels: - app: api-{{ .Name }} -spec: - ports: - - name: http-api-{{ .Name }} - protocol: TCP - port: 80 - targetPort: {{ .Port }} - selector: - app: api-{{ .Name }} - type: ClusterIP - sessionAffinity: None - ipFamilies: - - IPv4 - ipFamilyPolicy: SingleStack - -{{ if and .Host .Path }} ---- - -kind: Ingress -apiVersion: networking.k8s.io/v1 -metadata: - name: api-{{ .Name }} - namespace: {{ .NameSpace }} - annotations: - kubesphere.io/creator: drone - nginx.ingress.kubernetes.io/enable-cors: 'true' - nginx.ingress.kubernetes.io/rewrite-target: /$1 - nginx.ingress.kubernetes.io/use-regex: 'true' -spec: - rules: - - host: {{ .Host }} - http: - paths: - - path: {{ .Path }} - pathType: ImplementationSpecific - backend: - service: - name: api-{{ .Name }} - port: - number: 80 -{{ end }} + kube_certificate: + from_secret: kubernetes_cert + chart: ./{{ .Root }}/deploy + release: api-{{ .Name }} + wait: true + values: + - nameSpace={{ .NameSpace }} + - aliasName={{ .AliasName }} + - image=reg.icechen.cn/{{ .NameSpace }}/api-{{ .Name }} + - imageTag=${DRONE_TAG} + - port={{ .Port }} ` diff --git a/go_handler/go_handler_template/go_api_test_pipeline.go b/go_handler/go_handler_template/go_api_test_pipeline.go index 703280b..1a2cab6 100644 --- a/go_handler/go_handler_template/go_api_test_pipeline.go +++ b/go_handler/go_handler_template/go_api_test_pipeline.go @@ -21,135 +21,21 @@ steps: dockerfile: ./{{ .Root }}/Dockerfile - name: deploy - image: sinlead/drone-kubectl + image: bitsbeats/drone-helm3 settings: - kubernetes_server: + kube_api_server: from_secret: kubernetes_server_test - kubernetes_cert: - from_secret: kubernetes_cert_test - kubernetes_token: + kube_token: from_secret: kubernetes_token_test - commands: - - |- -echo ` + ApiTestDeploy + ` | kubectl apply -f - -# - kubectl wait --for=condition=Ready --timeout=300s -f deploy/deployment.yaml -` - -const ApiTestDeploy = `kind: Deployment -apiVersion: apps/v1 -metadata: - name: api-{{ .Name }}-test - namespace: {{ .NameSpace }} - labels: - app: api-{{ .Name }}-test - annotations: - kubesphere.io/alias-name: {{ .AliasName }} - kubesphere.io/creator: drone -spec: - replicas: 1 - selector: - matchLabels: - app: api-{{ .Name }}-test - template: - metadata: - creationTimestamp: null - labels: - app: api-{{ .Name }}-test - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - containers: - - image: 'reg.icechen.cn/{{ .NameSpace }}/api-{{ .Name }}:${DRONE_COMMIT:0:8}' - ports: - - containerPort: {{ .Port }} - protocol: TCP - envFrom: - - configMapRef: - name: service - env: - - name: endpoints - value: 'etcd:2379' - resources: - limits: - cpu: 200m - memory: 1000Mi - requests: - cpu: 50m - memory: 200Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: IfNotPresent - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - serviceAccountName: default - serviceAccount: default - securityContext: {} - imagePullSecrets: - - name: registry-secret - schedulerName: default-scheduler - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 25% - maxSurge: 25% - revisionHistoryLimit: 10 - progressDeadlineSeconds: 600 - ---- - -kind: Service -apiVersion: v1 -metadata: - name: api-{{ .Name }}-test - namespace: {{ .NameSpace }} - labels: - app: api-{{ .Name }}-test -spec: - ports: - - name: http-api-{{ .Name }}-test - protocol: TCP - port: 80 - targetPort: {{ .Port }} - selector: - app: api-{{ .Name }}-test - type: ClusterIP - sessionAffinity: None - ipFamilies: - - IPv4 - ipFamilyPolicy: SingleStack - -{{ if and .Host .Path }} ---- - -kind: Ingress -apiVersion: networking.k8s.io/v1 -metadata: - name: api-{{ .Name }}-test - namespace: {{ .NameSpace }} - annotations: - kubesphere.io/creator: drone - nginx.ingress.kubernetes.io/enable-cors: 'true' - nginx.ingress.kubernetes.io/rewrite-target: /$1 - nginx.ingress.kubernetes.io/use-regex: 'true' -spec: - rules: - - host: t{{ .Host }} - http: - paths: - - path: {{ .Path }} - pathType: ImplementationSpecific - backend: - service: - name: api-{{ .Name }}-test - port: - number: 80 -{{ end }} + kube_certificate: + from_secret: kubernetes_cert_test + chart: ./{{ .Root }}/deploy + release: api-{{ .Name }} + wait: true + values: + - nameSpace={{ .NameSpace }} + - aliasName={{ .AliasName }} + - image=reg.icechen.cn/{{ .NameSpace }}/api-{{ .Name }} + - imageTag=${DRONE_COMMIT:0:8} + - port={{ .Port }} ` diff --git a/go_handler/go_handler_template/go_service_production_pipeline.go b/go_handler/go_handler_template/go_service_production_pipeline.go index 01b82b7..c888ffa 100644 --- a/go_handler/go_handler_template/go_service_production_pipeline.go +++ b/go_handler/go_handler_template/go_service_production_pipeline.go @@ -21,108 +21,21 @@ steps: dockerfile: ./{{ .Root }}/Dockerfile - name: deploy - image: sinlead/drone-kubectl + image: bitsbeats/drone-helm3 settings: - kubernetes_server: + kube_api_server: from_secret: kubernetes_server - kubernetes_cert: - from_secret: kubernetes_cert - kubernetes_token: + kube_token: from_secret: kubernetes_token - commands: - - |- -echo ` + ServiceProductionDeploy + ` | kubectl apply -f - -# - kubectl wait --for=condition=Ready --timeout=300s -f deploy/deployment.yaml -` - -const ServiceProductionDeploy = `kind: Deployment -apiVersion: apps/v1 -metadata: - name: service-{{ .Name }} - namespace: {{ .NameSpace }} - labels: - app: service-{{ .Name }} - annotations: - kubesphere.io/alias-name: {{ .AliasName }} - kubesphere.io/creator: drone -spec: - replicas: 1 - selector: - matchLabels: - app: service-{{ .Name }} - template: - metadata: - creationTimestamp: null - labels: - app: service-{{ .Name }} - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - containers: - - image: 'reg.icechen.cn/{{ .NameSpace }}/service-{{ .Name }}:${DRONE_TAG}' - ports: - - containerPort: {{ .Port }} - protocol: TCP - envFrom: - - configMapRef: - name: service - env: - - name: endpoints - value: 'etcd:2379' - resources: - limits: - cpu: 200m - memory: 1000Mi - requests: - cpu: 50m - memory: 200Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: IfNotPresent - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - serviceAccountName: default - serviceAccount: default - securityContext: {} - imagePullSecrets: - - name: registry-secret - schedulerName: default-scheduler - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 25% - maxSurge: 25% - revisionHistoryLimit: 10 - progressDeadlineSeconds: 600 - ---- - -kind: Service -apiVersion: v1 -metadata: - name: service-{{ .Name }} - namespace: {{ .NameSpace }} - labels: - app: service-{{ .Name }} -spec: - ports: - - name: http-service-{{ .Name }} - protocol: TCP - port: 80 - targetPort: {{ .Port }} - selector: - app: service-{{ .Name }} - type: ClusterIP - sessionAffinity: None - ipFamilies: - - IPv4 - ipFamilyPolicy: SingleStack + kube_certificate: + from_secret: kubernetes_cert + chart: ./{{ .Root }}/deploy + release: service-{{ .Name }} + wait: true + values: + - nameSpace={{ .NameSpace }} + - aliasName={{ .AliasName }} + - image=reg.icechen.cn/{{ .NameSpace }}/service-{{ .Name }} + - imageTag=${DRONE_TAG} + - port={{ .Port }} ` diff --git a/go_handler/go_handler_template/go_service_test_pipeline.go b/go_handler/go_handler_template/go_service_test_pipeline.go index 4010309..94da166 100644 --- a/go_handler/go_handler_template/go_service_test_pipeline.go +++ b/go_handler/go_handler_template/go_service_test_pipeline.go @@ -21,108 +21,21 @@ steps: dockerfile: ./{{ .Root }}/Dockerfile - name: deploy - image: sinlead/drone-kubectl + image: bitsbeats/drone-helm3 settings: - kubernetes_server: + kube_api_server: from_secret: kubernetes_server_test - kubernetes_cert: - from_secret: kubernetes_cert_test - kubernetes_token: + kube_token: from_secret: kubernetes_token_test - commands: - - |- -echo ` + ServiceTestDeploy + ` | kubectl apply -f - -# - kubectl wait --for=condition=Ready --timeout=300s -f deploy/deployment.yaml -` - -const ServiceTestDeploy = `kind: Deployment -apiVersion: apps/v1 -metadata: - name: service-{{ .Name }}-test - namespace: {{ .NameSpace }} - labels: - app: service-{{ .Name }}-test - annotations: - kubesphere.io/alias-name: {{ .AliasName }} - kubesphere.io/creator: drone -spec: - replicas: 1 - selector: - matchLabels: - app: service-{{ .Name }}-test - template: - metadata: - creationTimestamp: null - labels: - app: service-{{ .Name }}-test - spec: - volumes: - - name: host-time - hostPath: - path: /etc/localtime - type: '' - containers: - - image: 'reg.icechen.cn/{{ .NameSpace }}/service-{{ .Name }}:${DRONE_COMMIT:0:8}' - ports: - - containerPort: {{ .Port }} - protocol: TCP - envFrom: - - configMapRef: - name: service - env: - - name: endpoints - value: 'etcd:2379' - resources: - limits: - cpu: 200m - memory: 1000Mi - requests: - cpu: 50m - memory: 200Mi - volumeMounts: - - name: host-time - readOnly: true - mountPath: /etc/localtime - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - imagePullPolicy: IfNotPresent - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - serviceAccountName: default - serviceAccount: default - securityContext: {} - imagePullSecrets: - - name: registry-secret - schedulerName: default-scheduler - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 25% - maxSurge: 25% - revisionHistoryLimit: 10 - progressDeadlineSeconds: 600 - ---- - -kind: Service -apiVersion: v1 -metadata: - name: service-{{ .Name }}-test - namespace: {{ .NameSpace }} - labels: - app: service-{{ .Name }}-test -spec: - ports: - - name: http-service-{{ .Name }}-test - protocol: TCP - port: 80 - targetPort: {{ .Port }} - selector: - app: service-{{ .Name }}-test - type: ClusterIP - sessionAffinity: None - ipFamilies: - - IPv4 - ipFamilyPolicy: SingleStack + kube_certificate: + from_secret: kubernetes_cert_test + chart: ./{{ .Root }}/deploy + release: service-{{ .Name }} + wait: true + values: + - nameSpace={{ .NameSpace }} + - aliasName={{ .AliasName }} + - image=reg.icechen.cn/{{ .NameSpace }}/service-{{ .Name }} + - imageTag=${DRONE_COMMIT:0:8} + - port={{ .Port }} `