From 6af4080f90e8f64e89dc48d09e5047c1a24374a9 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Fri, 5 Apr 2024 22:49:57 +0200 Subject: [PATCH 01/11] #3 Non-functioning. Unfortunately if I can't find a way to create toml from helm chart will need to change config format for the app. --- helm/Chart.yaml | 6 ++++++ helm/config.toml | 31 +++++++++++++++++++++++++++++++ helm/templates/configmap.yaml | 8 ++++++++ helm/templates/deployment.yaml | 25 +++++++++++++++++++++++++ helm/templates/service.yaml | 12 ++++++++++++ helm/values.yaml | 28 ++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+) create mode 100644 helm/Chart.yaml create mode 100644 helm/config.toml create mode 100644 helm/templates/configmap.yaml create mode 100644 helm/templates/deployment.yaml create mode 100644 helm/templates/service.yaml create mode 100644 helm/values.yaml diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..902984e --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: slackwatch +description: A Helm chart for Kubernetes to deploy Slackwatch +type: application +version: 0.1.0 +appVersion: "1.0" diff --git a/helm/config.toml b/helm/config.toml new file mode 100644 index 0000000..7c87b8a --- /dev/null +++ b/helm/config.toml @@ -0,0 +1,31 @@ + +[system] +schedule = "0 0 9-22/2 * * *" +data_dir = "/app/slackwatch/data" + +[notifications.ntfy] +url = "http://localhost:9090" +topic = "slackwatch" +priorty = 1 +reminder = "24h" +token = "dummy" + + +[[gitops]] +name = "fleet-slack-house" +repository_url = "https://github.com/slackspace-io/slackwatch.git" +branch = "main" +access_token_env_name = "SLACKWATCH_TOKEN" +commit_message = "Updated by slackwatch" +commit_name = "slackwatch" +commit_email = "slackwatch@slackspace.io" + +[[gitops]] +name = "noauth" +repository_url = "https://github.com/slackspace-io/slackwatch.git" +branch = "main" +access_token_env_name = "your_github_access_token_for_repoA" +commit_message = "Updated by slackwatch" +commit_name = "slackwatch" +commit_email = "slackwatch@slackspace.io" + diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml new file mode 100644 index 0000000..28203c6 --- /dev/null +++ b/helm/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config +data: + {{- $files:= .Files}} + config.toml: |- + {{$files.Get "config.toml"}} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml new file mode 100644 index 0000000..aaeea9d --- /dev/null +++ b/helm/templates/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: slackwatch + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-config diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml new file mode 100644 index 0000000..b934a7e --- /dev/null +++ b/helm/templates/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + selector: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..a2f53df --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,28 @@ +replicaCount: 1 + +image: + repository: ghcr.io/slackspace-io/slackwatch + pullPolicy: IfNotPresent + tag: "latest" + +service: + type: ClusterIP + port: 8080 + +config: + schedule: "0 15 9-22/2 * * *" + data_dir: "/app/slackwatch/data" + ntfy: + url: "http://ntfy.ntfy.svc.cluster.local" + topic: "slackwatch" + reminder: "24h" + token: "dummy" + +gitops: + - name: "dummy" + repository_url: "https://github.com/slackspace-io/dummy.git" + branch: "main" + commit_message: "Updated by slackwatch" + commit_name: "slackwatch" + commit_email: "slackwatch@slackspace.io" + access_token_env_name: "SLACKWATCH_TOKEN" From 448f4e45dd31d947f6501afbb68e917434879401 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Fri, 5 Apr 2024 22:49:57 +0200 Subject: [PATCH 02/11] #3 Non-functioning. Unfortunately if I can't find a way to create toml from helm chart will need to change config format for the app. --- helm/Chart.yaml | 6 ++++++ helm/config.toml | 31 +++++++++++++++++++++++++++++++ helm/templates/configmap.yaml | 8 ++++++++ helm/templates/deployment.yaml | 25 +++++++++++++++++++++++++ helm/templates/service.yaml | 12 ++++++++++++ helm/values.yaml | 28 ++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+) create mode 100644 helm/Chart.yaml create mode 100644 helm/config.toml create mode 100644 helm/templates/configmap.yaml create mode 100644 helm/templates/deployment.yaml create mode 100644 helm/templates/service.yaml create mode 100644 helm/values.yaml diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..902984e --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: slackwatch +description: A Helm chart for Kubernetes to deploy Slackwatch +type: application +version: 0.1.0 +appVersion: "1.0" diff --git a/helm/config.toml b/helm/config.toml new file mode 100644 index 0000000..7c87b8a --- /dev/null +++ b/helm/config.toml @@ -0,0 +1,31 @@ + +[system] +schedule = "0 0 9-22/2 * * *" +data_dir = "/app/slackwatch/data" + +[notifications.ntfy] +url = "http://localhost:9090" +topic = "slackwatch" +priorty = 1 +reminder = "24h" +token = "dummy" + + +[[gitops]] +name = "fleet-slack-house" +repository_url = "https://github.com/slackspace-io/slackwatch.git" +branch = "main" +access_token_env_name = "SLACKWATCH_TOKEN" +commit_message = "Updated by slackwatch" +commit_name = "slackwatch" +commit_email = "slackwatch@slackspace.io" + +[[gitops]] +name = "noauth" +repository_url = "https://github.com/slackspace-io/slackwatch.git" +branch = "main" +access_token_env_name = "your_github_access_token_for_repoA" +commit_message = "Updated by slackwatch" +commit_name = "slackwatch" +commit_email = "slackwatch@slackspace.io" + diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml new file mode 100644 index 0000000..28203c6 --- /dev/null +++ b/helm/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config +data: + {{- $files:= .Files}} + config.toml: |- + {{$files.Get "config.toml"}} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml new file mode 100644 index 0000000..aaeea9d --- /dev/null +++ b/helm/templates/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: slackwatch + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-config diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml new file mode 100644 index 0000000..b934a7e --- /dev/null +++ b/helm/templates/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + selector: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..a2f53df --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,28 @@ +replicaCount: 1 + +image: + repository: ghcr.io/slackspace-io/slackwatch + pullPolicy: IfNotPresent + tag: "latest" + +service: + type: ClusterIP + port: 8080 + +config: + schedule: "0 15 9-22/2 * * *" + data_dir: "/app/slackwatch/data" + ntfy: + url: "http://ntfy.ntfy.svc.cluster.local" + topic: "slackwatch" + reminder: "24h" + token: "dummy" + +gitops: + - name: "dummy" + repository_url: "https://github.com/slackspace-io/dummy.git" + branch: "main" + commit_message: "Updated by slackwatch" + commit_name: "slackwatch" + commit_email: "slackwatch@slackspace.io" + access_token_env_name: "SLACKWATCH_TOKEN" From 83746d3fecbabb7c999b89c726a2e7dd09ff862a Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 11:51:37 +0200 Subject: [PATCH 03/11] #3 - Changing to a yaml config format instead of toml to make helm simpler. I also have not enjoyed toml, so this is a good excuse. Need a new build so I can test the helm chart. --- .github/workflows/slackwatch.yml | 1 + src/config.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slackwatch.yml b/.github/workflows/slackwatch.yml index 6c6ec37..7436778 100644 --- a/.github/workflows/slackwatch.yml +++ b/.github/workflows/slackwatch.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - helm-wip paths: - 'src/**' diff --git a/src/config.rs b/src/config.rs index fc1f42a..fc3d947 100644 --- a/src/config.rs +++ b/src/config.rs @@ -50,7 +50,8 @@ impl Settings { let s = Config::builder() //add source if env var slackwatch_config path is set .add_source(File::with_name("/app/config/config").required(false)) - .add_source(File::with_name(".env.toml").required(false)) +// .add_source(File::with_name(".env.toml").required(false)) + .add_source(File::with_name(".env.yaml").required(false)) .add_source(File::with_name(&env_config).required(false)) .add_source(Environment::with_prefix("slackwatch")) .build()?; From 25b2ba67edc230034cbb161d4ce38f5efec09806 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:39:25 +0200 Subject: [PATCH 04/11] #3 - First attempt at creating the helm package, will probably blow up. --- .github/workflows/helm-release.yml | 35 +++++++++++++++ helm/templates/configmap.yaml | 7 +-- helm/templates/deployment.yaml | 12 +++-- helm/templates/ingress.yaml | 71 ++++++++++++++++++++++++++++++ helm/templates/rbac.yaml | 23 ++++++++++ helm/templates/role.yaml | 23 ++++++++++ helm/templates/service.yaml | 4 +- helm/templates/serviceaccount.yaml | 5 +++ helm/values.yaml | 57 +++++++++++++++++------- 9 files changed, 212 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/helm-release.yml create mode 100644 helm/templates/ingress.yaml create mode 100644 helm/templates/rbac.yaml create mode 100644 helm/templates/role.yaml create mode 100644 helm/templates/serviceaccount.yaml diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml new file mode 100644 index 0000000..393c475 --- /dev/null +++ b/.github/workflows/helm-release.yml @@ -0,0 +1,35 @@ +name: Release Charts + +on: + push: + branches: + - main + - helm-wip + +jobs: + release: + # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions + # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + with: + charts_dir: helm + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 28203c6..12aa0fe 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -3,6 +3,7 @@ kind: ConfigMap metadata: name: {{ .Chart.Name }}-config data: - {{- $files:= .Files}} - config.toml: |- - {{$files.Get "config.toml"}} + config.yaml: | + {{- if .Values.config }} + {{- toYaml .Values.config | nindent 4 }} + {{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index aaeea9d..1951c99 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} spec: replicas: {{ .Values.replicaCount }} selector: @@ -14,12 +15,17 @@ spec: app.kubernetes.io/name: {{ .Chart.Name }} app.kubernetes.io/instance: {{ .Release.Name }} spec: + serviceAccountName: {{ .Chart.Name }}-serviceaccount containers: - name: slackwatch image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - containerPort: {{ .Values.service.port }} - envFrom: - - configMapRef: - name: {{ .Chart.Name }}-config + volumeMounts: + - name: config-volume + mountPath: /app/config + volumes: + - name: config-volume + configMap: + name: {{ .Chart.Name }}-config diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml new file mode 100644 index 0000000..1ad27a8 --- /dev/null +++ b/helm/templates/ingress.yaml @@ -0,0 +1,71 @@ +{{- if .Values.ingress.enabled -}} +{{- $paths := .Values.ingress.paths -}} +{{- $extraPaths := .Values.ingress.extraPaths -}} +{{- $pathType := .Values.ingress.pathType -}} +{{- $servicePort := .Values.service.port -}} +{{- $serviceName := .Chart.Name}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Chart.Name }}-ingress + namespace: {{ .Release.Namespace | quote }} + labels: + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.ingressClassName }} + ingressClassName: {{ . }} + {{- end }} + rules: + {{- if .Values.ingress.hosts }} + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host | quote }} + http: + paths: + {{- with $extraPaths }} + {{- toYaml . | nindent 10 }} + {{- end }} + {{- range $p := $paths }} + - path: {{ $p }} + pathType: {{ $pathType }} + backend: + service: + name: {{ $serviceName }}-svc + port: + {{- if kindIs "float64" $servicePort }} + number: {{ $servicePort }} + {{- else }} + name: {{ $servicePort }} + {{- end }} + {{- end -}} + {{- end -}} + {{- else }} + - http: + paths: + {{- with $extraPaths }} + {{- toYaml . | nindent 10 }} + {{- end }} + {{- range $p := $paths }} + - path: {{ $p }} + pathType: {{ $pathType }} + backend: + service: + name: {{ .Chart.Name }}-svc + port: + {{- if kindIs "float64" $servicePort }} + number: {{ $servicePort }} + {{- else }} + name: {{ $servicePort }} + {{- end }} + {{- end -}} + {{- end -}} + {{- with .Values.ingress.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helm/templates/rbac.yaml b/helm/templates/rbac.yaml new file mode 100644 index 0000000..de40a64 --- /dev/null +++ b/helm/templates/rbac.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Chart.Name }}-clusterrole + namespace: {{ .Release.Namespace }} +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + namespace: {{ .Release.Namespace }} + name: {{ .Chart.Name }}-clusterrolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Chart.Name }}-clusterrole +subjects: +- kind: ServiceAccount + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/helm/templates/role.yaml b/helm/templates/role.yaml new file mode 100644 index 0000000..ec65433 --- /dev/null +++ b/helm/templates/role.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: {{ .Release.Namespace }} + name: {{ .Chart.Name }}-role +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Chart.Name }}-rolebinding + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ .Chart.Name }}-role +subjects: +- kind: ServiceAccount + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml index b934a7e..258b459 100644 --- a/helm/templates/service.yaml +++ b/helm/templates/service.yaml @@ -1,12 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Chart.Name }} + name: {{ .Chart.Name }}-svc spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} - targetPort: http + targetPort: 8080 selector: app.kubernetes.io/name: {{ .Chart.Name }} app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml new file mode 100644 index 0000000..03e3e7b --- /dev/null +++ b/helm/templates/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/helm/values.yaml b/helm/values.yaml index a2f53df..65fd649 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,28 +1,51 @@ replicaCount: 1 +namespace: slackwatch image: - repository: ghcr.io/slackspace-io/slackwatch + repository: ghcr.io/slackspace-io/slackwatch # Assuming this image is accessible as a placeholder pullPolicy: IfNotPresent tag: "latest" service: + annotations: {} + labels: {} type: ClusterIP - port: 8080 + port: 80 + +ingress: + enabled: false + labels: {} + ingressClassName: "" + paths: + - / + pathType: Prefix + extraPaths: [] + https: false + annotations: {} + tls: [] + hosts: + - test.slackwatch.default # Placeholder domain config: - schedule: "0 15 9-22/2 * * *" - data_dir: "/app/slackwatch/data" - ntfy: - url: "http://ntfy.ntfy.svc.cluster.local" - topic: "slackwatch" - reminder: "24h" - token: "dummy" + system: + #default schedule is every 2 hours + schedule: "0 0 */2 * *" + data_dir: "/app/slackwatch/data" + + notifications: + ntfy: + url: "http://ntfy-server.default:80" # Assumes an 'ntfy-server' available in the 'default' namespace + topic: "slackwatch-test" + token: "slackwatch-ntfy-token" + priority: 1 + reminder: "24h" + # ... other notification provider settings -gitops: - - name: "dummy" - repository_url: "https://github.com/slackspace-io/dummy.git" - branch: "main" - commit_message: "Updated by slackwatch" - commit_name: "slackwatch" - commit_email: "slackwatch@slackspace.io" - access_token_env_name: "SLACKWATCH_TOKEN" + gitops: + - name: "test-repo" # Placeholder name + repository_url: "https://github.com/your-org/test-repo.git" + branch: "main" + access_token_env_name: "TEST_REPO_ACCESS_TOKEN" + commit_message: "Automated commit by slackwatch" + commit_email: "slackwatch@yourmail.default" + # ... other GitOps settings From 5b4734c7b079112ca1f30bc317e19e3f0609be8a Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:46:34 +0200 Subject: [PATCH 05/11] #3 - Restructure to hopefully generate release --- .github/workflows/helm-release.yml | 2 - helm/Chart.yaml | 6 --- helm/templates/configmap.yaml | 9 ---- helm/templates/deployment.yaml | 31 ------------- helm/templates/ingress.yaml | 71 ------------------------------ helm/templates/rbac.yaml | 23 ---------- helm/templates/role.yaml | 23 ---------- helm/templates/service.yaml | 12 ----- helm/templates/serviceaccount.yaml | 5 --- helm/values.yaml | 51 --------------------- 10 files changed, 233 deletions(-) delete mode 100644 helm/Chart.yaml delete mode 100644 helm/templates/configmap.yaml delete mode 100644 helm/templates/deployment.yaml delete mode 100644 helm/templates/ingress.yaml delete mode 100644 helm/templates/rbac.yaml delete mode 100644 helm/templates/role.yaml delete mode 100644 helm/templates/service.yaml delete mode 100644 helm/templates/serviceaccount.yaml delete mode 100644 helm/values.yaml diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml index 393c475..8792cc5 100644 --- a/.github/workflows/helm-release.yml +++ b/.github/workflows/helm-release.yml @@ -29,7 +29,5 @@ jobs: - name: Run chart-releaser uses: helm/chart-releaser-action@v1.6.0 - with: - charts_dir: helm env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/helm/Chart.yaml b/helm/Chart.yaml deleted file mode 100644 index 902984e..0000000 --- a/helm/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: slackwatch -description: A Helm chart for Kubernetes to deploy Slackwatch -type: application -version: 0.1.0 -appVersion: "1.0" diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml deleted file mode 100644 index 12aa0fe..0000000 --- a/helm/templates/configmap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Chart.Name }}-config -data: - config.yaml: | - {{- if .Values.config }} - {{- toYaml .Values.config | nindent 4 }} - {{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml deleted file mode 100644 index 1951c99..0000000 --- a/helm/templates/deployment.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Chart.Name }} - namespace: {{ .Release.Namespace }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} - spec: - serviceAccountName: {{ .Chart.Name }}-serviceaccount - containers: - - name: slackwatch - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - containerPort: {{ .Values.service.port }} - volumeMounts: - - name: config-volume - mountPath: /app/config - volumes: - - name: config-volume - configMap: - name: {{ .Chart.Name }}-config diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml deleted file mode 100644 index 1ad27a8..0000000 --- a/helm/templates/ingress.yaml +++ /dev/null @@ -1,71 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $paths := .Values.ingress.paths -}} -{{- $extraPaths := .Values.ingress.extraPaths -}} -{{- $pathType := .Values.ingress.pathType -}} -{{- $servicePort := .Values.service.port -}} -{{- $serviceName := .Chart.Name}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ .Chart.Name }}-ingress - namespace: {{ .Release.Namespace | quote }} - labels: - {{- with .Values.ingress.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- with .Values.ingress.ingressClassName }} - ingressClassName: {{ . }} - {{- end }} - rules: - {{- if .Values.ingress.hosts }} - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host | quote }} - http: - paths: - {{- with $extraPaths }} - {{- toYaml . | nindent 10 }} - {{- end }} - {{- range $p := $paths }} - - path: {{ $p }} - pathType: {{ $pathType }} - backend: - service: - name: {{ $serviceName }}-svc - port: - {{- if kindIs "float64" $servicePort }} - number: {{ $servicePort }} - {{- else }} - name: {{ $servicePort }} - {{- end }} - {{- end -}} - {{- end -}} - {{- else }} - - http: - paths: - {{- with $extraPaths }} - {{- toYaml . | nindent 10 }} - {{- end }} - {{- range $p := $paths }} - - path: {{ $p }} - pathType: {{ $pathType }} - backend: - service: - name: {{ .Chart.Name }}-svc - port: - {{- if kindIs "float64" $servicePort }} - number: {{ $servicePort }} - {{- else }} - name: {{ $servicePort }} - {{- end }} - {{- end -}} - {{- end -}} - {{- with .Values.ingress.tls }} - tls: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/helm/templates/rbac.yaml b/helm/templates/rbac.yaml deleted file mode 100644 index de40a64..0000000 --- a/helm/templates/rbac.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ .Chart.Name }}-clusterrole - namespace: {{ .Release.Namespace }} -rules: -- apiGroups: ["*"] - resources: ["*"] - verbs: ["*"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - namespace: {{ .Release.Namespace }} - name: {{ .Chart.Name }}-clusterrolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ .Chart.Name }}-clusterrole -subjects: -- kind: ServiceAccount - name: {{ .Chart.Name }}-serviceaccount - namespace: {{ .Release.Namespace }} diff --git a/helm/templates/role.yaml b/helm/templates/role.yaml deleted file mode 100644 index ec65433..0000000 --- a/helm/templates/role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - namespace: {{ .Release.Namespace }} - name: {{ .Chart.Name }}-role -rules: -- apiGroups: ["*"] - resources: ["*"] - verbs: ["*"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: {{ .Chart.Name }}-rolebinding - namespace: {{ .Release.Namespace }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: {{ .Chart.Name }}-role -subjects: -- kind: ServiceAccount - name: {{ .Chart.Name }}-serviceaccount - namespace: {{ .Release.Namespace }} diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml deleted file mode 100644 index 258b459..0000000 --- a/helm/templates/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ .Chart.Name }}-svc -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: 8080 - selector: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml deleted file mode 100644 index 03e3e7b..0000000 --- a/helm/templates/serviceaccount.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ .Chart.Name }}-serviceaccount - namespace: {{ .Release.Namespace }} diff --git a/helm/values.yaml b/helm/values.yaml deleted file mode 100644 index 65fd649..0000000 --- a/helm/values.yaml +++ /dev/null @@ -1,51 +0,0 @@ -replicaCount: 1 -namespace: slackwatch - -image: - repository: ghcr.io/slackspace-io/slackwatch # Assuming this image is accessible as a placeholder - pullPolicy: IfNotPresent - tag: "latest" - -service: - annotations: {} - labels: {} - type: ClusterIP - port: 80 - -ingress: - enabled: false - labels: {} - ingressClassName: "" - paths: - - / - pathType: Prefix - extraPaths: [] - https: false - annotations: {} - tls: [] - hosts: - - test.slackwatch.default # Placeholder domain - -config: - system: - #default schedule is every 2 hours - schedule: "0 0 */2 * *" - data_dir: "/app/slackwatch/data" - - notifications: - ntfy: - url: "http://ntfy-server.default:80" # Assumes an 'ntfy-server' available in the 'default' namespace - topic: "slackwatch-test" - token: "slackwatch-ntfy-token" - priority: 1 - reminder: "24h" - # ... other notification provider settings - - gitops: - - name: "test-repo" # Placeholder name - repository_url: "https://github.com/your-org/test-repo.git" - branch: "main" - access_token_env_name: "TEST_REPO_ACCESS_TOKEN" - commit_message: "Automated commit by slackwatch" - commit_email: "slackwatch@yourmail.default" - # ... other GitOps settings From 60a6e8c55b26d68bf0610da176de5b9a9651488f Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:48:48 +0200 Subject: [PATCH 06/11] #3 - Restructure to hopefully generate release --- .gitignore | 2 +- charts/slackwatch/Chart.yaml | 6 ++ charts/slackwatch/templates/configmap.yaml | 9 +++ charts/slackwatch/templates/deployment.yaml | 31 ++++++++ charts/slackwatch/templates/ingress.yaml | 71 +++++++++++++++++++ charts/slackwatch/templates/rbac.yaml | 23 ++++++ charts/slackwatch/templates/role.yaml | 23 ++++++ charts/slackwatch/templates/service.yaml | 12 ++++ .../slackwatch/templates/serviceaccount.yaml | 5 ++ charts/slackwatch/values.yaml | 51 +++++++++++++ 10 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 charts/slackwatch/Chart.yaml create mode 100644 charts/slackwatch/templates/configmap.yaml create mode 100644 charts/slackwatch/templates/deployment.yaml create mode 100644 charts/slackwatch/templates/ingress.yaml create mode 100644 charts/slackwatch/templates/rbac.yaml create mode 100644 charts/slackwatch/templates/role.yaml create mode 100644 charts/slackwatch/templates/service.yaml create mode 100644 charts/slackwatch/templates/serviceaccount.yaml create mode 100644 charts/slackwatch/values.yaml diff --git a/.gitignore b/.gitignore index a9ce187..197d1b5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ docker-compose*.yml # Dioxus .dioxus/ -slackwatch/ +.slackwatch/ # Rust target/ diff --git a/charts/slackwatch/Chart.yaml b/charts/slackwatch/Chart.yaml new file mode 100644 index 0000000..902984e --- /dev/null +++ b/charts/slackwatch/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: slackwatch +description: A Helm chart for Kubernetes to deploy Slackwatch +type: application +version: 0.1.0 +appVersion: "1.0" diff --git a/charts/slackwatch/templates/configmap.yaml b/charts/slackwatch/templates/configmap.yaml new file mode 100644 index 0000000..12aa0fe --- /dev/null +++ b/charts/slackwatch/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config +data: + config.yaml: | + {{- if .Values.config }} + {{- toYaml .Values.config | nindent 4 }} + {{- end }} diff --git a/charts/slackwatch/templates/deployment.yaml b/charts/slackwatch/templates/deployment.yaml new file mode 100644 index 0000000..1951c99 --- /dev/null +++ b/charts/slackwatch/templates/deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + serviceAccountName: {{ .Chart.Name }}-serviceaccount + containers: + - name: slackwatch + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + volumeMounts: + - name: config-volume + mountPath: /app/config + volumes: + - name: config-volume + configMap: + name: {{ .Chart.Name }}-config diff --git a/charts/slackwatch/templates/ingress.yaml b/charts/slackwatch/templates/ingress.yaml new file mode 100644 index 0000000..1ad27a8 --- /dev/null +++ b/charts/slackwatch/templates/ingress.yaml @@ -0,0 +1,71 @@ +{{- if .Values.ingress.enabled -}} +{{- $paths := .Values.ingress.paths -}} +{{- $extraPaths := .Values.ingress.extraPaths -}} +{{- $pathType := .Values.ingress.pathType -}} +{{- $servicePort := .Values.service.port -}} +{{- $serviceName := .Chart.Name}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Chart.Name }}-ingress + namespace: {{ .Release.Namespace | quote }} + labels: + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.ingressClassName }} + ingressClassName: {{ . }} + {{- end }} + rules: + {{- if .Values.ingress.hosts }} + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host | quote }} + http: + paths: + {{- with $extraPaths }} + {{- toYaml . | nindent 10 }} + {{- end }} + {{- range $p := $paths }} + - path: {{ $p }} + pathType: {{ $pathType }} + backend: + service: + name: {{ $serviceName }}-svc + port: + {{- if kindIs "float64" $servicePort }} + number: {{ $servicePort }} + {{- else }} + name: {{ $servicePort }} + {{- end }} + {{- end -}} + {{- end -}} + {{- else }} + - http: + paths: + {{- with $extraPaths }} + {{- toYaml . | nindent 10 }} + {{- end }} + {{- range $p := $paths }} + - path: {{ $p }} + pathType: {{ $pathType }} + backend: + service: + name: {{ .Chart.Name }}-svc + port: + {{- if kindIs "float64" $servicePort }} + number: {{ $servicePort }} + {{- else }} + name: {{ $servicePort }} + {{- end }} + {{- end -}} + {{- end -}} + {{- with .Values.ingress.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/slackwatch/templates/rbac.yaml b/charts/slackwatch/templates/rbac.yaml new file mode 100644 index 0000000..de40a64 --- /dev/null +++ b/charts/slackwatch/templates/rbac.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Chart.Name }}-clusterrole + namespace: {{ .Release.Namespace }} +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + namespace: {{ .Release.Namespace }} + name: {{ .Chart.Name }}-clusterrolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Chart.Name }}-clusterrole +subjects: +- kind: ServiceAccount + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/charts/slackwatch/templates/role.yaml b/charts/slackwatch/templates/role.yaml new file mode 100644 index 0000000..ec65433 --- /dev/null +++ b/charts/slackwatch/templates/role.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: {{ .Release.Namespace }} + name: {{ .Chart.Name }}-role +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Chart.Name }}-rolebinding + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ .Chart.Name }}-role +subjects: +- kind: ServiceAccount + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/charts/slackwatch/templates/service.yaml b/charts/slackwatch/templates/service.yaml new file mode 100644 index 0000000..258b459 --- /dev/null +++ b/charts/slackwatch/templates/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-svc +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8080 + selector: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/slackwatch/templates/serviceaccount.yaml b/charts/slackwatch/templates/serviceaccount.yaml new file mode 100644 index 0000000..03e3e7b --- /dev/null +++ b/charts/slackwatch/templates/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Chart.Name }}-serviceaccount + namespace: {{ .Release.Namespace }} diff --git a/charts/slackwatch/values.yaml b/charts/slackwatch/values.yaml new file mode 100644 index 0000000..65fd649 --- /dev/null +++ b/charts/slackwatch/values.yaml @@ -0,0 +1,51 @@ +replicaCount: 1 +namespace: slackwatch + +image: + repository: ghcr.io/slackspace-io/slackwatch # Assuming this image is accessible as a placeholder + pullPolicy: IfNotPresent + tag: "latest" + +service: + annotations: {} + labels: {} + type: ClusterIP + port: 80 + +ingress: + enabled: false + labels: {} + ingressClassName: "" + paths: + - / + pathType: Prefix + extraPaths: [] + https: false + annotations: {} + tls: [] + hosts: + - test.slackwatch.default # Placeholder domain + +config: + system: + #default schedule is every 2 hours + schedule: "0 0 */2 * *" + data_dir: "/app/slackwatch/data" + + notifications: + ntfy: + url: "http://ntfy-server.default:80" # Assumes an 'ntfy-server' available in the 'default' namespace + topic: "slackwatch-test" + token: "slackwatch-ntfy-token" + priority: 1 + reminder: "24h" + # ... other notification provider settings + + gitops: + - name: "test-repo" # Placeholder name + repository_url: "https://github.com/your-org/test-repo.git" + branch: "main" + access_token_env_name: "TEST_REPO_ACCESS_TOKEN" + commit_message: "Automated commit by slackwatch" + commit_email: "slackwatch@yourmail.default" + # ... other GitOps settings From 9c341c77719aea2b9a6665cccb070555189d54ee Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:49:12 +0200 Subject: [PATCH 07/11] #3 - Restructure to hopefully generate release --- charts/slackwatch/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/slackwatch/Chart.yaml b/charts/slackwatch/Chart.yaml index 902984e..fc3971b 100644 --- a/charts/slackwatch/Chart.yaml +++ b/charts/slackwatch/Chart.yaml @@ -3,4 +3,4 @@ name: slackwatch description: A Helm chart for Kubernetes to deploy Slackwatch type: application version: 0.1.0 -appVersion: "1.0" +appVersion: "0.3.3" From e62511d2ba827a2ed5a0dded86c6e9bf8255b6a1 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:49:58 +0200 Subject: [PATCH 08/11] #3 correct versioning --- charts/slackwatch/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/slackwatch/Chart.yaml b/charts/slackwatch/Chart.yaml index fc3971b..1d84472 100644 --- a/charts/slackwatch/Chart.yaml +++ b/charts/slackwatch/Chart.yaml @@ -3,4 +3,4 @@ name: slackwatch description: A Helm chart for Kubernetes to deploy Slackwatch type: application version: 0.1.0 -appVersion: "0.3.3" +appVersion: 0.3.3. From c99d963712615fc32ea57a19ddc8d5d1106b3ac5 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:50:59 +0200 Subject: [PATCH 09/11] #3 correct versioning --- charts/slackwatch/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/slackwatch/Chart.yaml b/charts/slackwatch/Chart.yaml index 1d84472..154db6e 100644 --- a/charts/slackwatch/Chart.yaml +++ b/charts/slackwatch/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: slackwatch description: A Helm chart for Kubernetes to deploy Slackwatch type: application -version: 0.1.0 -appVersion: 0.3.3. +version: 0.1.1 +appVersion: 0.3.3 From 57c8a70378d1cfa0ae12186c620b01edcb58aa4b Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 13:51:57 +0200 Subject: [PATCH 10/11] #3 - Create release called slackwatch-helm --- charts/slackwatch/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/slackwatch/Chart.yaml b/charts/slackwatch/Chart.yaml index 154db6e..33bbc0b 100644 --- a/charts/slackwatch/Chart.yaml +++ b/charts/slackwatch/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 -name: slackwatch +name: slackwatch-helm description: A Helm chart for Kubernetes to deploy Slackwatch type: application -version: 0.1.1 +version: 0.1.0 appVersion: 0.3.3 From c3f02acb6e1be7583d9b80ca1da87d8f36d5b3b2 Mon Sep 17 00:00:00 2001 From: Jacob Morgan Date: Sat, 6 Apr 2024 14:07:09 +0200 Subject: [PATCH 11/11] Try to redirect for helm --- .github/workflows/mdbook.yml | 2 +- book.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 8b8d822..2462908 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -7,7 +7,7 @@ name: Deploy mdBook site to Pages on: # Runs on pushes targeting the default branch push: - branches: ["main"] + branches: ["main", "helm-wip"] paths: - "docs/**" diff --git a/book.toml b/book.toml index 2424153..7f6e4cb 100644 --- a/book.toml +++ b/book.toml @@ -14,3 +14,6 @@ edition = "2021" default-theme = "ayu" git-repository-url = "https://github.com/slackspace-io/slackwatch" highlight-code = true + +[output.html.redirect] +"index.yaml" = "https://raw.githubusercontent.com/slackspace-io/slackwatch/gh-pages/index.yaml"