Update helmrelease

This commit is contained in:
Nikolai Rodionov 2024-05-04 18:42:28 +02:00
parent c520ba3a5c
commit bc7833754a
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
18 changed files with 276 additions and 18 deletions

View File

@ -9,7 +9,7 @@ spec:
gateways: gateways:
- istio-system/badhouseplants-net - istio-system/badhouseplants-net
hosts: hosts:
- "softplayer-backend.badhouseplants.net" - {{ .Values.config.hostname }}
http: http:
- match: - match:
- uri: - uri:

View File

@ -1,3 +1,5 @@
config:
hostname: softplayer.dev.badhouseplants.net
replicaCount: 1 replicaCount: 1
image: image:

View File

@ -9,7 +9,7 @@ spec:
gateways: gateways:
- istio-system/badhouseplants-net - istio-system/badhouseplants-net
hosts: hosts:
- "softplayer-web.badhouseplants.net" - {{ .Values.config.hostname }}
http: http:
- match: - match:
- uri: - uri:

View File

@ -1,3 +1,6 @@
config:
hostname: dev.badhouseplants.net
replicaCount: 1 replicaCount: 1
image: image:

View File

@ -28,3 +28,19 @@ spec:
value: $(params.environment) value: $(params.environment)
- name: namespace - name: namespace
value: $(params.namespace) value: $(params.namespace)
- name: cleanup-dns-records
retries: 3
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: cleanup-dns-records
- name: namespace
value: tekton-pipelines
params:
- name: environment
value: $(params.environment)
- name: namespace
value: $(params.namespace)

View File

@ -55,6 +55,28 @@ spec:
value: $(params.environment) value: $(params.environment)
- name: namespace - name: namespace
value: $(params.namespace) value: $(params.namespace)
- name: prepare-dns-records
retries: 3
runAfter:
- prepare-hetzner-infra
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: prepare-dns-records
- name: namespace
value: tekton-pipelines
workspaces:
- name: outputs
workspace: inventory
params:
- name: environment
value: $(params.environment)
- name: namespace
value: $(params.namespace)
- name: bootstrap-k3s - name: bootstrap-k3s
retries: 3 retries: 3
runAfter: runAfter:

View File

@ -0,0 +1,32 @@
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: install-app
namespace: {{ .Values.pipelineNamespace }}
labels:
{{- include "tekton-pipelines.labels" . | nindent 4 }}
spec:
params:
- name: environment
type: string
- name: namespace
type: string
tasks:
- name: install-app
retries: 3
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: install-app
- name: namespace
value: tekton-pipelines
params:
- name: environment
value: $(params.environment)
- name: namespace
value: $(params.namespace)
- name: application
value: $(params.application)

View File

@ -10,6 +10,11 @@ rules:
- apiGroups: [""] - apiGroups: [""]
resources: ["secrets", "configmaps"] resources: ["secrets", "configmaps"]
verbs: ["*"] verbs: ["*"]
- apiGroups:
- helm.toolkit.fluxcd.io
- source.toolkit.fluxcd.io
resources: ["*"]
verbs: ["*"]
--- ---
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount

View File

@ -97,7 +97,7 @@ spec:
kubectl create secret generic \ kubectl create secret generic \
"$(params.environment)"-config \ "$(params.environment)"-config \
--namespace "$(params.namespace)" \ --namespace "$(params.namespace)" \
--from-file=kubeconfig=/tmp/outputs/admin-default-config --from-file=value=/tmp/outputs/admin-default-config
workspaces: workspaces:
- name: outputs - name: outputs
description: A folder to store outputs description: A folder to store outputs

View File

@ -0,0 +1,40 @@
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: cleanup-dns-records
namespace: {{ .Values.pipelineNamespace }}
labels:
{{- include "tekton-pipelines.labels" . | nindent 4 }}
spec:
params:
- name: namespace
type: string
- name: environment
type: string
steps:
- name: get-provider-outputs
image: alpine/k8s:1.29.2
script: |-
#!/bin/sh
kubectl get configmap "$(params.environment)"-provider-outputs \
--namespace "$(params.namespace)" -o yaml \
| yq '.data."provider_outputs.yaml"' > /tmp/outputs/provider_outputs.yaml
- name: setup-dns
image: git.badhouseplants.net/softplayer/softplayer-coskgne:latest
env:
- name: SP_STATE
value: absent
- name: SP_ENV
value: $(params.environment)
- name: SOPS_AGE_KEY
value: {{ .Values.providers.hetzner.ageKey }}
script: |-
#!/bin/sh
ansible-playbook /src/playbooks/other/cloudflare/playbook.yml
workspaces:
- name: outputs
description: A folder to store outputs
optional: false
mountPath: /tmp/outputs

View File

@ -42,3 +42,7 @@ spec:
kubectl delete secret \ kubectl delete secret \
"$(params.environment)-config" \ "$(params.environment)-config" \
--namespace "$(params.namespace)" || true --namespace "$(params.namespace)" || true
kubectl delete configmap \
"$(params.environment)-provider-outputs" \
--namespace "$(params.namespace)" || true

View File

@ -19,7 +19,7 @@ spec:
#!/bin/sh #!/bin/sh
kubectl get secret "$(params.environment)"-config \ kubectl get secret "$(params.environment)"-config \
--namespace "$(params.namespace)" -o yaml \ --namespace "$(params.namespace)" -o yaml \
| yq '.data.kubeconfig' \ | yq '.data.value' \
| base64 -d > /tmp/outputs/config | base64 -d > /tmp/outputs/config
chmod 0600 /tmp/outputs/config chmod 0600 /tmp/outputs/config
- name: annonate-an-env-cm-installing - name: annonate-an-env-cm-installing

View File

@ -0,0 +1,47 @@
# ---------------------------------------------------------------------
# This task should create a flux resource that will deploy a helm
# chart to the environemnt
# -- Create an app secret with configs
# -- shell-operator is running a pipeline with confi
# -- Tekton is creating a flux HelmRelease resource
# ---------------------------------------------------------------------
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: install-app
namespace: {{ .Values.pipelineNamespace }}
labels:
{{- include "tekton-pipelines.labels" . | nindent 4 }}
spec:
params:
- name: namespace
type: string
- name: environment
type: string
- name: application
type: string
steps:
- name: create-an-app
image: fluxcd/flux-cli:v2.2.3
env:
- name: SP_STATE
value: present
- name: SP_ENV
value: $(params.environment)
- name: SP_APPLICATION
value: $(params.application)
- name: SP_ACCOUNT
value: $(params.namespace)
script: |-
#!/bin/sh
flux create source helm $SP_APPLICATION \
--namespace=$SP_ACCOUNT \
--url=oci://git.badhouseplants.net/softplayer/helm
flux create helmrelease $SP_APPLICATION \
--source=HelmRepository/$SP_APPLICATION \
--namespace=$SP_ACCOUNT \
--chart=helmrelease \
--values-from Secret/$SP_APPLICATION-config \
--kubeconfig-secret-ref=$SP_ENV-config \
--target-namespace=default

View File

@ -0,0 +1,48 @@
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: prepare-dns-records
namespace: {{ .Values.pipelineNamespace }}
labels:
{{- include "tekton-pipelines.labels" . | nindent 4 }}
spec:
params:
- name: namespace
type: string
- name: environment
type: string
steps:
- name: get-provider-outputs
image: alpine/k8s:1.29.2
script: |-
#!/bin/sh
kubectl get configmap "$(params.environment)"-provider-outputs \
--namespace "$(params.namespace)" -o yaml \
| yq '.data."provider_outputs.yaml"' > /tmp/outputs/provider_outputs.yaml
- 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=setting-up-dns"
- name: setup-dns
image: git.badhouseplants.net/softplayer/softplayer-coskgne:latest
env:
- name: SP_STATE
value: present
- name: SP_ENV
value: $(params.environment)
- name: SOPS_AGE_KEY
value: {{ .Values.providers.hetzner.ageKey }}
script: |-
#!/bin/sh
ansible-playbook /src/playbooks/other/cloudflare/playbook.yml
workspaces:
- name: outputs
description: A folder to store outputs
optional: false
mountPath: /tmp/outputs

View File

@ -55,6 +55,18 @@ spec:
"$(params.environment)"-inventory \ "$(params.environment)"-inventory \
--namespace "$(params.namespace)" \ --namespace "$(params.namespace)" \
--from-file /tmp/outputs/inventory.yaml --from-file /tmp/outputs/inventory.yaml
- name: save-provider-outputs
image: alpine/k8s:1.29.2
script: |-
#!/bin/sh
kubectl delete configmap \
"$(params.environment)"-provider-outputs \
--namespace "$(params.namespace)"
kubectl create configmap \
"$(params.environment)"-provider-outputs \
--namespace "$(params.namespace)" \
--from-file /tmp/outputs/provider_outputs.yaml
workspaces: workspaces:
- name: outputs - name: outputs
description: A folder to store outputs description: A folder to store outputs

View File

@ -41,7 +41,12 @@ repositories:
git: git:
url: https://git.badhouseplants.net/softplayer/softplayer-helmfile url: https://git.badhouseplants.net/softplayer/softplayer-helmfile
git_ref: main git_ref: main
path: charts/helmrelease path: charts
- name: allanger-charts
git:
url: https://git.badhouseplants.net/allanger/helm-charts
git_ref: add-shadowsocks
path: charts
mirrors: mirrors:
- name: custom-commands - name: custom-commands
@ -122,3 +127,13 @@ charts:
repository: fluxcd-community repository: fluxcd-community
mirrors: mirrors:
- custom_command - custom_command
- name: helmrelease
repository: softplayer
mirrors:
- custom_command
- name: shadowsocks-libev
repository: allanger-charts
mirrors:
- custom_command

View File

@ -47,9 +47,7 @@ releases:
- kube-system/cilium - kube-system/cilium
- kube-system/namespaces - kube-system/namespaces
values: values:
- policies: - ./values/flux.yaml
create: false
- name: cert-manager - name: cert-manager
chart: zot/cert-manager chart: zot/cert-manager
version: v1.14.4 version: v1.14.4
@ -84,4 +82,10 @@ releases:
- name: local-path-provisioner - name: local-path-provisioner
chart: zot/local-path-provisioner chart: zot/local-path-provisioner
version: 0.0.25-dev version: 0.0.25-dev
needs:
- kube-system/namespaces
- kube-system/coredns
- kube-system/cilium
namespace: traefik-system

View File

@ -0,0 +1,8 @@
policies:
create: false
kustomizeController:
create: false
imageAutomationController:
create: false
imageReflectionController:
create: false