From 9e43b4c0cbc74c9d0417788e9085358ffe4000c2 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Mon, 2 Sep 2024 14:53:57 +0200 Subject: [PATCH] feat: helm-chart support Signed-off-by: Bence Csati --- .github/workflows/artifacts.yaml | 26 ++++++++++ .../charts/kube-pod-autocomplete/.helmignore | 21 ++++++++ .../charts/kube-pod-autocomplete/Chart.yaml | 10 ++++ .../kube-pod-autocomplete-deployment.yaml | 27 +++++++++++ .../templates/kube-pod-autocomplete-rbac.yaml | 32 +++++++++++++ .../kube-pod-autocomplete-service.yaml | 13 +++++ .../charts/kube-pod-autocomplete/values.yaml | 30 ++++++++++++ deploy/kube-pod-autocomplete.yaml | 48 ------------------- deploy/rbac.yaml | 31 ------------ 9 files changed, 159 insertions(+), 79 deletions(-) create mode 100644 deploy/charts/kube-pod-autocomplete/.helmignore create mode 100644 deploy/charts/kube-pod-autocomplete/Chart.yaml create mode 100644 deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-deployment.yaml create mode 100644 deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-rbac.yaml create mode 100644 deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-service.yaml create mode 100644 deploy/charts/kube-pod-autocomplete/values.yaml delete mode 100644 deploy/kube-pod-autocomplete.yaml delete mode 100644 deploy/rbac.yaml diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 939df3e..123fb50 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -112,3 +112,29 @@ jobs: with: name: Kube-Pod-Autocomplete-Binary path: build/dist/* + + helm-chart: + name: Helm-Chart + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.15.4 + + - name: Helm lint + run: make lint-helm + + - name: Helm package + id: build + run: make helm-chart + + - name: Upload Helm chart artifact + uses: actions/upload-artifact@v4 + with: + name: Kube-Pod-Autocomplete-Helm-Chart + path: build/*.tgz diff --git a/deploy/charts/kube-pod-autocomplete/.helmignore b/deploy/charts/kube-pod-autocomplete/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/deploy/charts/kube-pod-autocomplete/Chart.yaml b/deploy/charts/kube-pod-autocomplete/Chart.yaml new file mode 100644 index 0000000..b9d8fdf --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +type: application +name: kube-pod-autocomplete +version: 0.0.0 +appVersion: latest +description: backend service designed to enhance the user experience when navigating resource lists in Kubernetes clusters. +sources: + - https://github.com/csatib02/kube-pod-autocomplete +maintainers: + - name: csatib02 diff --git a/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-deployment.yaml b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-deployment.yaml new file mode 100644 index 0000000..18b81b3 --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }} + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: {{ .Values.name }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Values.name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ .Values.name }} + spec: + serviceAccountName: {{ .Values.serviceAccount.name }} + containers: + - name: {{ .Values.name }} + image: {{ .Values.image }} + ports: + - containerPort: {{ .Values.containerPort }} + resources: + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} diff --git a/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-rbac.yaml b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-rbac.yaml new file mode 100644 index 0000000..2577b1a --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-rbac.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serviceAccount.name }} + namespace: {{ .Values.namespace }} + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Values.rbac.clusterRoleName }} + namespace: {{ .Values.namespace }} +rules: +- apiGroups: [""] + resources: + {{- toYaml .Values.rbac.resourceTypes | nindent 4 }} + verbs: ["get", "list"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Values.rbac.clusterRoleBindingName }} + namespace: {{ .Values.namespace }} +subjects: +- kind: ServiceAccount + name: {{ .Values.serviceAccount.name }} + namespace: {{ .Values.namespace }} +roleRef: + kind: ClusterRole + name: {{ .Values.rbac.clusterRoleName }} + apiGroup: rbac.authorization.k8s.io diff --git a/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-service.yaml b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-service.yaml new file mode 100644 index 0000000..594939a --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/templates/kube-pod-autocomplete-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }} + namespace: {{ .Values.namespace }} +spec: + selector: + app.kubernetes.io/name: {{ .Values.name }} + type: {{ .Values.service.type }} + ports: + - protocol: TCP + port: {{ .Values.servicePort }} + targetPort: {{ .Values.containerPort }} diff --git a/deploy/charts/kube-pod-autocomplete/values.yaml b/deploy/charts/kube-pod-autocomplete/values.yaml new file mode 100644 index 0000000..e62b9a0 --- /dev/null +++ b/deploy/charts/kube-pod-autocomplete/values.yaml @@ -0,0 +1,30 @@ +# Namespace where the application will be deployed +namespace: kube-pod-autocomplete + +# General settings for the service +name: kube-pod-autocomplete +replicas: 1 +image: csatib02/kube-pod-autocomplete:v0.1.0 +containerPort: 8080 +servicePort: 8080 + +# Service settings +service: + type: ClusterIP + +# Service Account settings +serviceAccount: + name: kube-pod-autocomplete-sa + +# RBAC settings +rbac: + clusterRoleName: kube-pod-autocomplete-clusterrole + resourceTypes: + - "pods" + clusterRoleBindingName: kube-pod-autocomplete-clusterrolebinding + +# Resource limits for the application +resources: + limits: + cpu: "1" + memory: "512Mi" diff --git a/deploy/kube-pod-autocomplete.yaml b/deploy/kube-pod-autocomplete.yaml deleted file mode 100644 index e256b78..0000000 --- a/deploy/kube-pod-autocomplete.yaml +++ /dev/null @@ -1,48 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: kube-pod-autocomplete - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: kube-pod-autocomplete - namespace: kube-pod-autocomplete - labels: - app.kubernetes.io/name: kube-pod-autocomplete -spec: - replicas: 1 - selector: - matchLabels: - app.kubernetes.io/name: kube-pod-autocomplete - template: - metadata: - labels: - app.kubernetes.io/name: kube-pod-autocomplete - spec: - serviceAccountName: kube-pod-autocomplete-sa - containers: - - name: kube-pod-autocomplete - image: csatib02/kube-pod-autocomplete:v0.1.0 - ports: - - containerPort: 8080 - resources: - limits: - cpu: "1" - memory: "512Mi" - ---- -apiVersion: v1 -kind: Service -metadata: - name: kube-pod-autocomplete - namespace: kube-pod-autocomplete -spec: - selector: - app.kubernetes.io/name: kube-pod-autocomplete - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 - type: ClusterIP diff --git a/deploy/rbac.yaml b/deploy/rbac.yaml deleted file mode 100644 index c56e9cc..0000000 --- a/deploy/rbac.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: kube-pod-autocomplete-sa - namespace: kube-pod-autocomplete - ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: kube-pod-autocomplete-clusterrole - namespace: kube-pod-autocomplete -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get", "list"] - ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: kube-pod-autocomplete-clusterrolebinding - namespace: kube-pod-autocomplete -subjects: -- kind: ServiceAccount - name: kube-pod-autocomplete-sa - namespace: kube-pod-autocomplete -roleRef: - kind: ClusterRole - name: kube-pod-autocomplete-clusterrole - apiGroup: rbac.authorization.k8s.io