From 9f657f9bd02ae0e3be48a989eb7c9a1efd573c97 Mon Sep 17 00:00:00 2001 From: itzaname Date: Tue, 15 Nov 2022 21:57:35 -0500 Subject: [PATCH] Update CI to new infra --- .drone.yaml | 55 --------------------- .drone.yml | 42 ++++++++++++++++ chart/.helmignore | 23 --------- chart/Chart.yaml | 24 --------- chart/templates/_helpers.tpl | 62 ------------------------ chart/templates/hpa.yaml | 28 ----------- chart/templates/secret.yaml | 9 ---- chart/templates/statefulset.yaml | 83 -------------------------------- chart/values.yaml | 56 --------------------- 9 files changed, 42 insertions(+), 340 deletions(-) delete mode 100644 .drone.yaml create mode 100644 .drone.yml delete mode 100644 chart/.helmignore delete mode 100644 chart/Chart.yaml delete mode 100644 chart/templates/_helpers.tpl delete mode 100644 chart/templates/hpa.yaml delete mode 100644 chart/templates/secret.yaml delete mode 100644 chart/templates/statefulset.yaml delete mode 100644 chart/values.yaml diff --git a/.drone.yaml b/.drone.yaml deleted file mode 100644 index f9d8959..0000000 --- a/.drone.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -kind: pipeline -type: docker - -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: gcr.io/kaniko-project/executor:latest - entrypoint: [ /kaniko/executor ] - command: [ "--context=/drone/src", "--dockerfile=Dockerfile", "--destination=image", "--no-push", "--tarPath=maptest-bot.tar" ] - -- name: scan-image - image: aquasec/trivy:latest - commands: - - trivy image --exit-code 1 --severity CRITICAL --input maptest-bot.tar - -- name: push-image - image: alpine:3 - commands: - - wget -qO- https://github.com/google/go-containerregistry/releases/download/v0.9.0/go-containerregistry_Linux_x86_64.tar.gz | tar xvz -C /usr/bin/ - - crane auth login -u $REGISTRY_USER -p $REGISTRY_PASS $REGISTRY_URL - - crane push maptest-bot.tar $REGISTRY_URL/strafesnet/maptest-bot:latest - - crane push maptest-bot.tar $REGISTRY_URL/strafesnet/maptest-bot:master-$DRONE_BUILD_NUMBER - environment: - REGISTRY_URL: - from_secret: REGISTRY_URL - REGISTRY_USER: - from_secret: REGISTRY_USER - REGISTRY_PASS: - from_secret: REGISTRY_PASS - when: - ref: - - refs/heads/master - -- name: deploy - image: alpine/helm:latest - commands: - - mkdir ~/.kube && echo "$KUBE_CONF_DEV" > ~/.kube/config && chmod 600 ~/.kube/config - - helm upgrade -i --namespace=strafesnet-dev maptest-bot --set config="$(echo $APP_CONFIG | base64 -w0)" --set image.tag=master-$DRONE_BUILD_NUMBER chart - environment: - APP_CONFIG: - from_secret: APP_CONFIG - KUBE_CONF_DEV: - from_secret: KUBE_CONF_DEV - when: - ref: - - refs/heads/master - -trigger: - ref: - - refs/heads/master - - refs/pull/*/head \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..927f192 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,42 @@ +--- +kind: pipeline +type: docker + +platform: + os: linux + arch: amd64 + +steps: + - name: image + image: plugins/docker + settings: + registry: registry.itzana.me + repo: registry.itzana.me/strafesnet/maptest-bot + tags: + - ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER} + - ${DRONE_BRANCH} + username: + from_secret: REGISTRY_USER + password: + from_secret: REGISTRY_PASS + when: + branch: + - master + + - name: deploy + image: argoproj/argocd:latest + commands: + - argocd login --grpc-web cd.stricity.com --username $USERNAME --password $PASSWORD + - argocd app --grpc-web set ${DRONE_BRANCH}-maptest-bot --kustomize-image registry.itzana.me/strafesnet/maptest-bot:${DRONE_BRANCH}-${DRONE_BUILD_NUMBER} + environment: + USERNAME: + from_secret: ARGO_USER + PASSWORD: + from_secret: ARGO_PASS + when: + branch: + - master + +trigger: + ref: + - refs/heads/master \ No newline at end of file diff --git a/chart/.helmignore b/chart/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/chart/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/chart/Chart.yaml b/chart/Chart.yaml deleted file mode 100644 index 4f430fd..0000000 --- a/chart/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: maptest-bot -description: Map test bot helm chart - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "1.16.0" diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl deleted file mode 100644 index dc12e56..0000000 --- a/chart/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "maptest-bot.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "maptest-bot.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "maptest-bot.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "maptest-bot.labels" -}} -helm.sh/chart: {{ include "maptest-bot.chart" . }} -{{ include "maptest-bot.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "maptest-bot.selectorLabels" -}} -app.kubernetes.io/name: {{ include "maptest-bot.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "maptest-bot.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "maptest-bot.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/chart/templates/hpa.yaml b/chart/templates/hpa.yaml deleted file mode 100644 index 67864d7..0000000 --- a/chart/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "maptest-bot.fullname" . }} - labels: - {{- include "maptest-bot.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "maptest-bot.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/chart/templates/secret.yaml b/chart/templates/secret.yaml deleted file mode 100644 index 43525d0..0000000 --- a/chart/templates/secret.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -data: - config.json: {{ .Values.config | quote }} -kind: Secret -metadata: - name: {{ include "maptest-bot.fullname" . }}-config - labels: - {{- include "maptest-bot.labels" . | nindent 4 }} -type: Opaque \ No newline at end of file diff --git a/chart/templates/statefulset.yaml b/chart/templates/statefulset.yaml deleted file mode 100644 index 5901dbc..0000000 --- a/chart/templates/statefulset.yaml +++ /dev/null @@ -1,83 +0,0 @@ -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ include "maptest-bot.fullname" . }} - labels: - {{- include "maptest-bot.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "maptest-bot.selectorLabels" . | nindent 6 }} - serviceName: {{ include "maptest-bot.fullname" . }} - volumeClaimTemplates: - - metadata: - name: map-submits - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 1Gi - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "maptest-bot.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - command: ["node"] - args: ["bot.js"] - volumeMounts: - - name: config - mountPath: "/app/config" - readOnly: true - - name: map-submits - mountPath: "/app/files" - initContainers: - - name: {{ .Chart.Name }}-init - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - command: ["node"] - args: ["deploy-commands.js"] - volumeMounts: - - name: config - mountPath: "/app/config" - readOnly: true - volumes: - - name: config - secret: - secretName: {{ include "maptest-bot.fullname" . }}-config - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/chart/values.yaml b/chart/values.yaml deleted file mode 100644 index 2cb0e0e..0000000 --- a/chart/values.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# Default values for maptest-bot. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 -image: - repository: registry.itzana.me/strafesnet/maptest-bot - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "latest" - -imagePullSecrets: - - name: registry-itzaname -nameOverride: "" -fullnameOverride: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -config: "" -