Skip to content

Commit

Permalink
feat: create charts for istio-upgrade-worker and fix logic on deploym…
Browse files Browse the repository at this point in the history
…ent_freeze.go

Signed-off-by: Zufar Dhiyaullhaq <[email protected]>
  • Loading branch information
zufardhiyaulhaq committed Sep 28, 2024
1 parent a1a3c41 commit 3190382
Show file tree
Hide file tree
Showing 18 changed files with 392 additions and 19 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ image.release:
.PHONY: build.binaries
build.binaries:
CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags '${LDFLAGS}' -o ${BIN_DIR}/istio-upgrade-worker ./main.go

.PHONY: readme
readme:
helm-docs -c ./charts/istio-upgrade-worker -d > README.md
helm-docs -c ./charts/istio-upgrade-worker

.PHONY: helm.create.releases
helm.create.releases:
helm package charts/istio-upgrade-worker --destination charts/releases
helm repo index charts/releases
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# istio-upgrade-worker

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github main branch build](https://img.shields.io/github/workflow/status/gopaytech/istio-upgrade-worker/Main)](https://github.com/gopaytech/istio-upgrade-worker/actions/workflows/main.yml) [![GitHub issues](https://img.shields.io/github/issues/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/pulls)[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/istio-upgrade-worker)](https://artifacthub.io/packages/search?repo=istio-upgrade-worker)

## Installing

To install the chart with the release name `my-release`:

```console
helm repo add istio-upgrade-worker https://gopaytech.github.io/istio-upgrade-worker/charts/releases/
helm install my-istio-upgrade-worker istio-upgrade-worker/istio-upgrade-worker --values values.yaml
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| configuration.clusterName | string | `"my-cluster"` | |
| configuration.deploymentFreezeDates[0] | string | `"2024-01-01"` | |
| configuration.enableDeploymentFreeze | bool | `true` | |
| configuration.enableRolloutAtWeekend | bool | `false` | |
| configuration.istioNamespaceCanaryLabel | string | `"istio.io/rev=default"` | |
| configuration.istioNamespaceLabel | string | `"istio-injection=enabled"` | |
| configuration.maximumIteration | int | `5` | |
| configuration.maximumPercentageRolloutInSingleExecution | int | `20` | |
| configuration.notificationMode | string | `"slack"` | |
| configuration.preUpgradeNotificationSecond | int | `600` | |
| configuration.rolloutIntervalSecond | int | `30` | |
| configuration.slackWebhookSecretName | string | `"slack-webhook-secret"` | |
| configuration.storageConfigMapName | string | `"istio-auto-upgrade-config"` | |
| configuration.storageConfigMapNameSpace | string | `"istio-system"` | |
| configuration.storageMode | string | `"configmap"` | |
| configuration.timeFormat | string | `"2006-01-02"` | |
| configuration.timeLocation | string | `"Asia/Jakarta"` | |
| cronjob.image | string | `"ghcr.io/gopaytech/istio-upgrade-worker"` | |
| cronjob.schedule | string | `"32 5 * * *"` | |
| cronjob.tag | string | `"nightly"` | |
| cronjob.timeZone | string | `"Asia/Jakarta"` | |
| podLabels | object | `{}` | |
| resources.limits.cpu | string | `"200m"` | |
| resources.limits.memory | string | `"100Mi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"20Mi"` | |
| serviceAccount.automountServiceAccountToken | bool | `true` | |
| serviceAccount.imagePullSecrets | list | `[]` | |

23 changes: 23 additions & 0 deletions charts/istio-upgrade-worker/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
12 changes: 12 additions & 0 deletions charts/istio-upgrade-worker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: v2
name: istio-upgrade-worker
version: 1.0.0
appVersion: 1.0.0
type: application
home: https://github.com/gopaytech/istio-upgrade-worker

maintainers:
- name: Zufar Dhiyaulhaq
email: [email protected]
url: https://zufardhiyaulhaq.com
46 changes: 46 additions & 0 deletions charts/istio-upgrade-worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# istio-upgrade-worker

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github main branch build](https://img.shields.io/github/workflow/status/gopaytech/istio-upgrade-worker/Main)](https://github.com/gopaytech/istio-upgrade-worker/actions/workflows/main.yml) [![GitHub issues](https://img.shields.io/github/issues/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/pulls)[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/istio-upgrade-worker)](https://artifacthub.io/packages/search?repo=istio-upgrade-worker)

## Installing

To install the chart with the release name `my-release`:

```console
helm repo add istio-upgrade-worker https://gopaytech.github.io/istio-upgrade-worker/charts/releases/
helm install my-istio-upgrade-worker istio-upgrade-worker/istio-upgrade-worker --values values.yaml
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| configuration.clusterName | string | `"my-cluster"` | |
| configuration.deploymentFreezeDates[0] | string | `"2024-01-01"` | |
| configuration.enableDeploymentFreeze | bool | `true` | |
| configuration.enableRolloutAtWeekend | bool | `false` | |
| configuration.istioNamespaceCanaryLabel | string | `"istio.io/rev=default"` | |
| configuration.istioNamespaceLabel | string | `"istio-injection=enabled"` | |
| configuration.maximumIteration | int | `5` | |
| configuration.maximumPercentageRolloutInSingleExecution | int | `20` | |
| configuration.notificationMode | string | `"slack"` | |
| configuration.preUpgradeNotificationSecond | int | `600` | |
| configuration.rolloutIntervalSecond | int | `30` | |
| configuration.slackWebhookSecretName | string | `"slack-webhook-secret"` | |
| configuration.storageConfigMapName | string | `"istio-auto-upgrade-config"` | |
| configuration.storageConfigMapNameSpace | string | `"istio-system"` | |
| configuration.storageMode | string | `"configmap"` | |
| configuration.timeFormat | string | `"2006-01-02"` | |
| configuration.timeLocation | string | `"Asia/Jakarta"` | |
| cronjob.image | string | `"ghcr.io/gopaytech/istio-upgrade-worker"` | |
| cronjob.schedule | string | `"32 5 * * *"` | |
| cronjob.tag | string | `"nightly"` | |
| cronjob.timeZone | string | `"Asia/Jakarta"` | |
| podLabels | object | `{}` | |
| resources.limits.cpu | string | `"200m"` | |
| resources.limits.memory | string | `"100Mi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"20Mi"` | |
| serviceAccount.automountServiceAccountToken | bool | `true` | |
| serviceAccount.imagePullSecrets | list | `[]` | |

19 changes: 19 additions & 0 deletions charts/istio-upgrade-worker/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ template "chart.header" . }}
{{ template "chart.description" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}[![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github main branch build](https://img.shields.io/github/workflow/status/gopaytech/istio-upgrade-worker/Main)](https://github.com/gopaytech/istio-upgrade-worker/actions/workflows/main.yml) [![GitHub issues](https://img.shields.io/github/issues/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/gopaytech/istio-upgrade-worker)](https://github.com/gopaytech/istio-upgrade-worker/pulls)[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/istio-upgrade-worker)](https://artifacthub.io/packages/search?repo=istio-upgrade-worker)

## Installing

To install the chart with the release name `my-release`:

```console
helm repo add istio-upgrade-worker https://gopaytech.github.io/istio-upgrade-worker/charts/releases/
helm install my-istio-upgrade-worker istio-upgrade-worker/istio-upgrade-worker --values values.yaml
```

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}

{{ template "helm-docs.versionFooter" . }}
9 changes: 9 additions & 0 deletions charts/istio-upgrade-worker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- define "istio-upgrade-worker.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "istio-upgrade-worker.podlabels" -}}
{{- with .Values.podLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/istio-upgrade-worker/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["*"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["*"]
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["*"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["*"]

17 changes: 17 additions & 0 deletions charts/istio-upgrade-worker/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}
namespace: {{ .Values.serviceAccount.namespace }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-deployment-freeze
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
deployment-freeze.yaml: |-
dates:
{{- with .Values.configuration.deploymentFreezeDates }}
{{- toYaml . | nindent 4 }}
{{- end }}
31 changes: 31 additions & 0 deletions charts/istio-upgrade-worker/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
CLUSTER_NAME: {{ .Values.configuration.clusterName }}
ROLLOUT_INTERVAL_SECOND: {{ .Values.configuration.rolloutIntervalSecond }}
MAXIMUM_PERCENTAGE_ROLLOUT_SINGLE_EXECUTION: {{ .Values.configuration.maximumPercentageRolloutInSingleExecution }}
MAXIMUM_ITERATION: {{ .Values.configuration.maximumIteration }}
PRE_UPGRADE_NOTIFICATION_SECOND: {{ .Values.configuration.preUpgradeNotificationSecond }}

ENABLE_DEPLOYMENT_FREEZE: {{ .Values.configuration.enableDeploymentFreeze }}
DEPLOYMENT_FREEZE_CONFIG_FILE_PATH: "/etc/config/deployment-freeze/deployment-freeze.yaml"
ENABLE_ROLLOUT_AT_WEEKEND: {{ .Values.configuration.enableRolloutAtWeekend }}

TIME_LOCATION: {{ .Values.configuration.timeLocation }}
TIME_FORMAT: {{ .Values.configuration.timeFormat }}

STORAGE_MODE: {{ .Values.configuration.storageMode }}
STORAGE_CONFIGMAP_NAME: {{ .Values.configuration.storageConfigMapName }}
STORAGE_CONFIGMAP_NAMESPACE: {{ .Values.configuration.storageConfigMapNamespace }}

NOTIFICATION_MODE: {{ .Values.configuration.notificationMode }}

ISTIO_NAMESPACE_CANARY_LABEL: {{ .Values.configuration.istioNamespaceCanaryLabel }}
ISTIO_NAMESPACE_CANARY_LABEL: {{ .Values.configuration.istioNamespaceLabel }}
42 changes: 42 additions & 0 deletions charts/istio-upgrade-worker/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: batch/v1
kind: CronJob
metadata:
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
name: {{ .Release.Name }}
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.cronjob.schedule }}
timeZone: {{ .Values.cronjob.timeZone }}
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: {{ .Values.configuration.maximumIteration }}
jobTemplate:
spec:
template:
metadata:
labels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "istio-upgrade-worker.podlabels" . | nindent 12 }}
spec:
serviceAccount: {{ .Release.Name }}
volumes:
- name: deployment-freeze
configMap:
name: {{ .Release.Name }}-deployment-freeze
containers:
- name: istio-upgrade-worker
image: "{{ .Values.cronjob.image }}:{{ .Values.cronjob.tag }}"
imagePullPolicy: Always
volumeMounts:
- name: deployment-freeze
mountPath: /etc/config/deployment-freeze
envFrom:
- configMapRef:
name: {{ .Release.Name }}
{{ if eq .Values.configuration.notificationMode "slack" }}
- secretMapRef:
name: {{ .Values.configuration.slackWebhookSecretName }}
{{ end }}
12 changes: 12 additions & 0 deletions charts/istio-upgrade-worker/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}
helm.sh/chart: {{ template "istio-upgrade-worker.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
imagePullSecrets:
{{ toYaml .Values.serviceAccount.imagePullSecrets | indent 2 }}
45 changes: 45 additions & 0 deletions charts/istio-upgrade-worker/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cronjob:
image: "ghcr.io/gopaytech/istio-upgrade-worker"
tag: "nightly"
schedule: "32 5 * * *"
timeZone: 'Asia/Jakarta'

resources:
limits:
cpu: 200m
memory: 100Mi
requests:
cpu: 100m
memory: 20Mi

serviceAccount:
imagePullSecrets: []
automountServiceAccountToken: true

podLabels: {}

configuration:
clusterName: "my-cluster"
rolloutIntervalSecond: 30
maximumPercentageRolloutInSingleExecution: 20
maximumIteration: 5
preUpgradeNotificationSecond: 600

enableDeploymentFreeze: true
deploymentFreezeDates:
- "2024-01-01"
enableRolloutAtWeekend: false

timeLocation: "Asia/Jakarta"
timeFormat: "2006-01-02"

storageMode: "configmap"
storageConfigMapName: "istio-auto-upgrade-config"
storageConfigMapNameSpace: "istio-system"

notificationMode: slack
slackWebhookSecretName: slack-webhook-secret

istioNamespaceCanaryLabel: istio.io/rev=default
istioNamespaceLabel: istio-injection=enabled

18 changes: 18 additions & 0 deletions charts/releases/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
entries:
istio-upgrade-worker:
- apiVersion: v2
appVersion: 1.0.0
created: "2024-09-28T19:59:14.036468+07:00"
digest: e7d5aae647d00c02cd7f738578c38c548026c7c4ffe9da02f0125ea25ba086f5
home: https://github.com/gopaytech/istio-upgrade-worker
maintainers:
- email: [email protected]
name: Zufar Dhiyaulhaq
url: https://zufardhiyaulhaq.com
name: istio-upgrade-worker
type: application
urls:
- istio-upgrade-worker-1.0.0.tgz
version: 1.0.0
generated: "2024-09-28T19:59:14.035792+07:00"
Binary file added charts/releases/istio-upgrade-worker-1.0.0.tgz
Binary file not shown.
Loading

0 comments on commit 3190382

Please sign in to comment.