diff --git a/charts/softplayer-backend/.helmignore b/charts/softplayer-backend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/softplayer-backend/.helmignore @@ -0,0 +1,23 @@ +# 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/charts/softplayer-backend/Chart.yaml b/charts/softplayer-backend/Chart.yaml new file mode 100644 index 0000000..fc88a7c --- /dev/null +++ b/charts/softplayer-backend/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: softplayer-backend +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/charts/softplayer-backend/backup/virtual-service.yaml b/charts/softplayer-backend/backup/virtual-service.yaml new file mode 100644 index 0000000..b09c530 --- /dev/null +++ b/charts/softplayer-backend/backup/virtual-service.yaml @@ -0,0 +1,51 @@ +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} + namespace: istio-system +spec: + selector: + istio: ingressgateway + servers: + - hosts: + - '*' + port: + name: grpc-web + number: 8080 + protocol: HTTP2 + - hosts: + - '*' + port: + name: http + number: 80 + protocol: HTTP2 + - hosts: + - '*' + port: + name: https + number: 443 + protocol: HTTP2 +--- +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} +spec: + gateways: + - istio-system/{{ include "softplayer-backend.fullname" . }} + hosts: + - "*" + http: + - match: + - uri: + prefix: / + route: + - destination: + host: {{ include "softplayer-backend.fullname" . }} + port: + number: 54321 + diff --git a/charts/softplayer-backend/templates/NOTES.txt b/charts/softplayer-backend/templates/NOTES.txt new file mode 100644 index 0000000..7d790da --- /dev/null +++ b/charts/softplayer-backend/templates/NOTES.txt @@ -0,0 +1 @@ +1. Get the application URL by running these commands: diff --git a/charts/softplayer-backend/templates/_helpers.tpl b/charts/softplayer-backend/templates/_helpers.tpl new file mode 100644 index 0000000..e53259e --- /dev/null +++ b/charts/softplayer-backend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "softplayer-backend.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 "softplayer-backend.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 "softplayer-backend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "softplayer-backend.labels" -}} +helm.sh/chart: {{ include "softplayer-backend.chart" . }} +{{ include "softplayer-backend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "softplayer-backend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "softplayer-backend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "softplayer-backend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "softplayer-backend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/softplayer-backend/templates/deployment.yaml b/charts/softplayer-backend/templates/deployment.yaml new file mode 100644 index 0000000..4cd8189 --- /dev/null +++ b/charts/softplayer-backend/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} + {{- with .Values.deployAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "softplayer-backend.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "softplayer-backend.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "softplayer-backend.serviceAccountName" . }} + 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 }} + args: + - serve + - --reflection + - --smtp-host=badhouseplants.net + - --smtp-password='NCzs2fK8Gh5rAWxGte%!K54T7' + - --smtp-from=allanger@badhouseplants.net + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- 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/charts/softplayer-backend/templates/hpa.yaml b/charts/softplayer-backend/templates/hpa.yaml new file mode 100644 index 0000000..a486edb --- /dev/null +++ b/charts/softplayer-backend/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "softplayer-backend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/softplayer-backend/templates/rbac.yaml b/charts/softplayer-backend/templates/rbac.yaml new file mode 100644 index 0000000..3913787 --- /dev/null +++ b/charts/softplayer-backend/templates/rbac.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "softplayer-backend.fullname" . }} +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +# This cluster role binding allows anyone in the "manager" group to read secrets in any namespace. +kind: ClusterRoleBinding +metadata: + name: {{ include "softplayer-backend.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ include "softplayer-backend.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: ClusterRole + name: {{ include "softplayer-backend.fullname" . }} + apiGroup: rbac.authorization.k8s.io diff --git a/charts/softplayer-backend/templates/service.yaml b/charts/softplayer-backend/templates/service.yaml new file mode 100644 index 0000000..84745c0 --- /dev/null +++ b/charts/softplayer-backend/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 4020 + protocol: TCP + name: grpc-web + selector: + {{- include "softplayer-backend.selectorLabels" . | nindent 4 }} diff --git a/charts/softplayer-backend/templates/serviceaccount.yaml b/charts/softplayer-backend/templates/serviceaccount.yaml new file mode 100644 index 0000000..70b620e --- /dev/null +++ b/charts/softplayer-backend/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "softplayer-backend.serviceAccountName" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/softplayer-backend/templates/tests/test-connection.yaml b/charts/softplayer-backend/templates/tests/test-connection.yaml new file mode 100644 index 0000000..cc696be --- /dev/null +++ b/charts/softplayer-backend/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "softplayer-backend.fullname" . }}-test-connection" + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "softplayer-backend.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/softplayer-backend/templates/vs.yaml b/charts/softplayer-backend/templates/vs.yaml new file mode 100644 index 0000000..b036840 --- /dev/null +++ b/charts/softplayer-backend/templates/vs.yaml @@ -0,0 +1,47 @@ +--- +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ include "softplayer-backend.fullname" . }} + labels: + {{- include "softplayer-backend.labels" . | nindent 4 }} +spec: + gateways: + - istio-system/badhouseplants-net + hosts: + - "softplayer-backend.badhouseplants.net" + http: + - match: + - uri: + prefix: / + route: + - destination: + host: {{ include "softplayer-backend.fullname" . }} + port: + number: 80 + corsPolicy: + allowOrigin: + - "*" + allowMethods: + - POST + - GET + - OPTIONS + - PUT + - DELETE + allowHeaders: + - grpc-timeout + - content-type + - keep-alive + - user-agent + - cache-control + - content-type + - content-transfer-encoding + - custom-header-1 + - x-accept-content-transfer-encoding + - x-accept-response-streaming + - x-user-agent + - x-grpc-web + maxAge: 1728s + exposeHeaders: + - grpc-status + - grpc-message diff --git a/charts/softplayer-backend/values.yaml b/charts/softplayer-backend/values.yaml new file mode 100644 index 0000000..ffee264 --- /dev/null +++ b/charts/softplayer-backend/values.yaml @@ -0,0 +1,82 @@ +replicaCount: 1 + +image: + repository: git.badhouseplants.net/softplayer/softplayer-backend + pullPolicy: Always + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + automount: true + annotations: {} + name: "" + +deployAnnotations: + keel.sh/policy: force +podLabels: {} + +podSecurityContext: + fsGroup: 2000 + +securityContext: + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +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 + + ## livenessProbe: + ## httpGet: + ## path: / + ## port: http + ## readinessProbe: + ## httpGet: + ## path: / + ## port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/softplayer-web/.helmignore b/charts/softplayer-web/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/softplayer-web/.helmignore @@ -0,0 +1,23 @@ +# 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/charts/softplayer-web/Chart.yaml b/charts/softplayer-web/Chart.yaml new file mode 100644 index 0000000..70fb39f --- /dev/null +++ b/charts/softplayer-web/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: softplayer-web +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/charts/softplayer-web/backup/virtual-service.yaml b/charts/softplayer-web/backup/virtual-service.yaml new file mode 100644 index 0000000..252fe24 --- /dev/null +++ b/charts/softplayer-web/backup/virtual-service.yaml @@ -0,0 +1,51 @@ +apiVersion: networking.istio.io/v1beta1 +kind: Gateway +metadata: + name: {{ include "softplayer-web.fullname" . }} + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} + namespace: istio-system +spec: + selector: + istio: ingressgateway + servers: + - hosts: + - '*' + port: + name: grpc-web + number: 8080 + protocol: HTTP2 + - hosts: + - '*' + port: + name: http + number: 80 + protocol: HTTP2 + - hosts: + - '*' + port: + name: https + number: 443 + protocol: HTTP2 +--- +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ include "softplayer-web.fullname" . }} + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} +spec: + gateways: + - istio-system/{{ include "softplayer-web.fullname" . }} + hosts: + - "*" + http: + - match: + - uri: + prefix: / + route: + - destination: + host: {{ include "softplayer-web.fullname" . }} + port: + number: 54321 + diff --git a/charts/softplayer-web/templates/NOTES.txt b/charts/softplayer-web/templates/NOTES.txt new file mode 100644 index 0000000..7d790da --- /dev/null +++ b/charts/softplayer-web/templates/NOTES.txt @@ -0,0 +1 @@ +1. Get the application URL by running these commands: diff --git a/charts/softplayer-web/templates/_helpers.tpl b/charts/softplayer-web/templates/_helpers.tpl new file mode 100644 index 0000000..c0b7e8f --- /dev/null +++ b/charts/softplayer-web/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "softplayer-web.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 "softplayer-web.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 "softplayer-web.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "softplayer-web.labels" -}} +helm.sh/chart: {{ include "softplayer-web.chart" . }} +{{ include "softplayer-web.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "softplayer-web.selectorLabels" -}} +app.kubernetes.io/name: {{ include "softplayer-web.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "softplayer-web.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "softplayer-web.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/softplayer-web/templates/deployment.yaml b/charts/softplayer-web/templates/deployment.yaml new file mode 100644 index 0000000..3fa5e0e --- /dev/null +++ b/charts/softplayer-web/templates/deployment.yaml @@ -0,0 +1,76 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "softplayer-web.fullname" . }} + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} + {{- with .Values.deployAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "softplayer-web.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "softplayer-web.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + 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 }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + - mountPath: /var/cache/nginx + name: cache-volume + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + - name: cache-volume + emptyDir: + sizeLimit: 500Mi + {{- end }} + {{- 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/charts/softplayer-web/templates/service.yaml b/charts/softplayer-web/templates/service.yaml new file mode 100644 index 0000000..478a271 --- /dev/null +++ b/charts/softplayer-web/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "softplayer-web.fullname" . }} + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 80 + protocol: TCP + name: http + selector: + {{- include "softplayer-web.selectorLabels" . | nindent 4 }} diff --git a/charts/softplayer-web/templates/tests/test-connection.yaml b/charts/softplayer-web/templates/tests/test-connection.yaml new file mode 100644 index 0000000..5643a58 --- /dev/null +++ b/charts/softplayer-web/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "softplayer-web.fullname" . }}-test-connection" + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "softplayer-web.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/softplayer-web/templates/vs.yaml b/charts/softplayer-web/templates/vs.yaml new file mode 100644 index 0000000..a585eae --- /dev/null +++ b/charts/softplayer-web/templates/vs.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: networking.istio.io/v1beta1 +kind: VirtualService +metadata: + name: {{ include "softplayer-web.fullname" . }} + labels: + {{- include "softplayer-web.labels" . | nindent 4 }} +spec: + gateways: + - istio-system/badhouseplants-net + hosts: + - "softplayer-web.badhouseplants.net" + http: + - match: + - uri: + prefix: / + route: + - destination: + host: {{ include "softplayer-web.fullname" . }} + port: + number: 80 diff --git a/charts/softplayer-web/values.yaml b/charts/softplayer-web/values.yaml new file mode 100644 index 0000000..3206009 --- /dev/null +++ b/charts/softplayer-web/values.yaml @@ -0,0 +1,72 @@ +replicaCount: 1 + +image: + repository: git.badhouseplants.net/softplayer/softplayer-web + pullPolicy: Always + tag: 45a52d541049ac142c7144ab1da5de8c79be62ce + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + automount: true + annotations: {} + name: "" + +deployAnnotations: + keel.sh/policy: force +podLabels: {} + + +service: + type: ClusterIP + port: 80 + +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 + + ## livenessProbe: + ## httpGet: + ## path: / + ## port: http + ## readinessProbe: + ## httpGet: + ## path: / + ## port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/tekton-pipelines/templates/rbac.yaml b/charts/tekton-pipelines/templates/rbac.yaml index 9ffa51e..e2e460c 100644 --- a/charts/tekton-pipelines/templates/rbac.yaml +++ b/charts/tekton-pipelines/templates/rbac.yaml @@ -8,7 +8,7 @@ metadata: {{- include "tekton-pipelines.labels" . | nindent 4 }} rules: - apiGroups: [""] - resources: ["secrets"] + resources: ["secrets", "configmaps"] verbs: ["*"] --- apiVersion: v1 diff --git a/charts/tekton-pipelines/templates/tasks/bootstrap-k3s.yml b/charts/tekton-pipelines/templates/tasks/bootstrap-k3s.yml index 281db48..cd91f65 100644 --- a/charts/tekton-pipelines/templates/tasks/bootstrap-k3s.yml +++ b/charts/tekton-pipelines/templates/tasks/bootstrap-k3s.yml @@ -31,6 +31,14 @@ spec: | base64 -d > /tmp/outputs/inventory.yaml chmod 0600 /tmp/outputs/ssh_key chmod 0600 /tmp/outputs/ssh_key.pub + - name: annonate-an-env-cm + image: alpine/k8s:1.29.2 + script: |- + #!/bin/sh + kubectl annotate --overwrite configmap \ + "$(params.environment)" \ + --namespace "$(params.namespace)" \ + "softplayer.net/status=servers-configuration" - name: prepare-servers image: git.badhouseplants.net/softplayer/softplayer-coskgne:latest env: diff --git a/charts/tekton-pipelines/templates/tasks/cleanup-hetzner-infra.yml b/charts/tekton-pipelines/templates/tasks/cleanup-hetzner-infra.yml index 11b8bbf..3e90de9 100644 --- a/charts/tekton-pipelines/templates/tasks/cleanup-hetzner-infra.yml +++ b/charts/tekton-pipelines/templates/tasks/cleanup-hetzner-infra.yml @@ -35,10 +35,10 @@ spec: #!/bin/sh kubectl delete secret \ "$(params.environment)-inventory" \ - --namespace "$(params.namespace)" + --namespace "$(params.namespace)" || true kubectl delete secret \ "$(params.environment)-ssh" \ - --namespace "$(params.namespace)" + --namespace "$(params.namespace)" || true kubectl delete secret \ "$(params.environment)-config" \ - --namespace "$(params.namespace)" + --namespace "$(params.namespace)" || true diff --git a/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml b/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml index 432f2d1..e532e01 100644 --- a/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml +++ b/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml @@ -22,6 +22,14 @@ spec: | yq '.data.kubeconfig' \ | base64 -d > /tmp/outputs/config chmod 0600 /tmp/outputs/config + - name: annonate-an-env-cm + image: alpine/k8s:1.29.2 + script: |- + #!/bin/sh + kubectl annotate --overwrite configmap \ + "$(params.environment)" \ + --namespace "$(params.namespace)" \ + "softplayer.net/status=installing-dependencies" - name: deploy-helmfile image: ghcr.io/helmfile/helmfile:v0.163.1 env: @@ -32,6 +40,14 @@ spec: mkdir -p /src git clone https://git.badhouseplants.net/softplayer/softplayer-helmfile.git /src/helmfile cd /src/helmfile/workload && helmfile sync + - name: annonate-an-env-cm + image: alpine/k8s:1.29.2 + script: |- + #!/bin/sh + kubectl annotate --overwrite configmap \ + "$(params.environment)" \ + --namespace "$(params.namespace)" \ + "softplayer.net/status=ready" workspaces: - name: outputs description: A folder to store outputs diff --git a/charts/tekton-pipelines/templates/tasks/prepare-hetzner-infra.yml b/charts/tekton-pipelines/templates/tasks/prepare-hetzner-infra.yml index 24b87a1..9575fca 100644 --- a/charts/tekton-pipelines/templates/tasks/prepare-hetzner-infra.yml +++ b/charts/tekton-pipelines/templates/tasks/prepare-hetzner-infra.yml @@ -22,6 +22,14 @@ spec: | yq '.data."ssh_key.pub"' \ | base64 -d > /tmp/outputs/ssh_key.pub chmod 0600 /tmp/outputs/ssh_key.pub + - name: annonate-an-env-cm + image: alpine/k8s:1.29.2 + script: |- + #!/bin/sh + kubectl annotate --overwrite configmap \ + "$(params.environment)" \ + --namespace "$(params.namespace)" \ + "softplayer.net/status=infra-bootstrapping" - name: create-hetzner-infra image: git.badhouseplants.net/softplayer/softplayer-coskgne:latest env: diff --git a/service/helmfile.yaml b/service/helmfile.yaml index a54d0ce..ddf95e8 100644 --- a/service/helmfile.yaml +++ b/service/helmfile.yaml @@ -87,6 +87,8 @@ releases: chart: zot/local-path-provisioner namespace: kube-system version: 0.0.25-dev + values: + - ./values/local-path.yaml needs: - kube-system/namespaces - kube-system/coredns @@ -100,6 +102,7 @@ releases: - kube-system/namespaces - kube-system/coredns - kube-system/cilium + - name: istio-ingressgateway chart: istio/gateway namespace: istio-system @@ -107,8 +110,10 @@ releases: - kube-system/namespaces - kube-system/coredns - kube-system/cilium + - istio-system/istio-base values: - ./values/values.istio-ingressgateway.yaml + - name: istiod chart: istio/istiod namespace: istio-system @@ -118,3 +123,9 @@ releases: - kube-system/cilium values: - ./values/values.istiod.yaml + + - name: softplayer-backend + chart: ../charts/softplayer-backend + namespace: softplayer-backend + needs: + - istio-system/istio-ingressgateway diff --git a/service/values/local-path.yaml b/service/values/local-path.yaml new file mode 100644 index 0000000..511dd9a --- /dev/null +++ b/service/values/local-path.yaml @@ -0,0 +1,3 @@ +storageClass: + create: true + defaultClass: true