From 8eebe405b7afa763b7eee00415c99f8e18c38a3e Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Thu, 9 May 2024 11:40:36 +0200 Subject: [PATCH] Add a network-base for workload --- .../.helmignore | 0 charts/network-base-workload/Chart.yaml | 24 +++++++++ .../templates/_helpers.tpl | 51 +++++++++++++++++++ .../templates/issuer.yaml | 17 +++++++ charts/network-base-workload/values.yaml | 0 charts/rbac/.helmignore | 23 +++++++++ charts/{roles => rbac}/Chart.yaml | 0 charts/{roles => rbac}/templates/_helpers.tpl | 0 .../templates/roles.yaml} | 0 charts/{roles => rbac}/values.yaml | 2 +- .../templates/tasks/deploy-helmfile-base.yml | 4 ++ workload/helmfile.yaml | 7 +++ workload/values/kubernetes-dashboard.yaml | 21 ++++++++ 13 files changed, 148 insertions(+), 1 deletion(-) rename charts/{roles => network-base-workload}/.helmignore (100%) create mode 100644 charts/network-base-workload/Chart.yaml create mode 100644 charts/network-base-workload/templates/_helpers.tpl create mode 100644 charts/network-base-workload/templates/issuer.yaml create mode 100644 charts/network-base-workload/values.yaml create mode 100644 charts/rbac/.helmignore rename charts/{roles => rbac}/Chart.yaml (100%) rename charts/{roles => rbac}/templates/_helpers.tpl (100%) rename charts/{roles/templates/namespaces.yaml => rbac/templates/roles.yaml} (100%) rename charts/{roles => rbac}/values.yaml (78%) create mode 100644 workload/values/kubernetes-dashboard.yaml diff --git a/charts/roles/.helmignore b/charts/network-base-workload/.helmignore similarity index 100% rename from charts/roles/.helmignore rename to charts/network-base-workload/.helmignore diff --git a/charts/network-base-workload/Chart.yaml b/charts/network-base-workload/Chart.yaml new file mode 100644 index 0000000..eaa345a --- /dev/null +++ b/charts/network-base-workload/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: network-base +description: A Helm chart for Kubernetes + +# 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/charts/network-base-workload/templates/_helpers.tpl b/charts/network-base-workload/templates/_helpers.tpl new file mode 100644 index 0000000..10d731a --- /dev/null +++ b/charts/network-base-workload/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "network-base.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 "network-base.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 "network-base.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "network-base.labels" -}} +helm.sh/chart: {{ include "network-base.chart" . }} +{{ include "network-base.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "network-base.selectorLabels" -}} +app.kubernetes.io/name: {{ include "network-base.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/network-base-workload/templates/issuer.yaml b/charts/network-base-workload/templates/issuer.yaml new file mode 100644 index 0000000..62e64be --- /dev/null +++ b/charts/network-base-workload/templates/issuer.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: {{ include "network-base.fullname" . }} + labels: + {{- include "network-base.labels" $ | nindent 4 }} +spec: + acme: + email: allanger@zohomail.com + privateKeySecretRef: + name: {{ include "network-base.fullname" . }}-priv-key + server: https://acme-v02.api.letsencrypt.org/directory + solvers: + - http01: + ingress: + ingressClassName: traefik diff --git a/charts/network-base-workload/values.yaml b/charts/network-base-workload/values.yaml new file mode 100644 index 0000000..e69de29 diff --git a/charts/rbac/.helmignore b/charts/rbac/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/rbac/.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/roles/Chart.yaml b/charts/rbac/Chart.yaml similarity index 100% rename from charts/roles/Chart.yaml rename to charts/rbac/Chart.yaml diff --git a/charts/roles/templates/_helpers.tpl b/charts/rbac/templates/_helpers.tpl similarity index 100% rename from charts/roles/templates/_helpers.tpl rename to charts/rbac/templates/_helpers.tpl diff --git a/charts/roles/templates/namespaces.yaml b/charts/rbac/templates/roles.yaml similarity index 100% rename from charts/roles/templates/namespaces.yaml rename to charts/rbac/templates/roles.yaml diff --git a/charts/roles/values.yaml b/charts/rbac/values.yaml similarity index 78% rename from charts/roles/values.yaml rename to charts/rbac/values.yaml index 7fcd045..df40196 100644 --- a/charts/roles/values.yaml +++ b/charts/rbac/values.yaml @@ -6,4 +6,4 @@ roles: - apiGroups: ["*"] resources: ["*"] verbs: ["*"] - namespace: ["minecraft-application"] + namespace: ["minecraft-application"] \ No newline at end of file diff --git a/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml b/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml index 5011e9e..670f82b 100644 --- a/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml +++ b/charts/tekton-pipelines/templates/tasks/deploy-helmfile-base.yml @@ -21,6 +21,10 @@ spec: --namespace "$(params.namespace)" -o yaml \ | yq '.data.value' \ | base64 -d > /tmp/outputs/config + kubectl get configmap "$(params.environment)"-provider-outputs \ + --namespace "$(params.namespace)" -o yaml \ + | yq '.data."provider_outputs.yaml"' > /tmp/outputs/provider_outputs.yaml + chmod 0600 /tmp/outputs/config - name: annonate-an-env-cm-installing image: alpine/k8s:1.29.2 diff --git a/workload/helmfile.yaml b/workload/helmfile.yaml index a4dd5ea..5112dfa 100644 --- a/workload/helmfile.yaml +++ b/workload/helmfile.yaml @@ -97,6 +97,13 @@ releases: - kube-system/coredns - kube-system/cilium namespace: traefik-system + + - name: network-base + chart: ../charts/network-base-workload/ + needs: + - kube-system/namespaces + - cert-manager/cert-manager + - name: kubernetes-dashboard chart: zot/kubernetes-dashboard diff --git a/workload/values/kubernetes-dashboard.yaml b/workload/values/kubernetes-dashboard.yaml new file mode 100644 index 0000000..de80dc3 --- /dev/null +++ b/workload/values/kubernetes-dashboard.yaml @@ -0,0 +1,21 @@ + ingress: + enabled: true + hosts: + # Keep 'localhost' host only if you want to access Dashboard using 'kubectl port-forward ...' on: + # https://localhost:8443 + - localhost + # - kubernetes.dashboard.domain.com + ingressClassName: traefik + pathType: ImplementationSpecific + path: / + issuer: + name: selfsigned + # Scope determines what kind of issuer annotation will be used on ingress resource + # - default - adds 'cert-manager.io/issuer' + # - cluster - adds 'cert-manager.io/cluster-issuer' + # - disabled - disables cert-manager annotations + scope: cluster + tls: + secretName: "" + labels: {} + annotations: {} \ No newline at end of file