Skip to content

Commit

Permalink
chore: helm charts
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-segning committed Aug 13, 2024
1 parent 3c42742 commit 2438d15
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 186 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ jobs:
run: cross build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client

- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client wazuh-cert-oauth2-client-${{ matrix.target }}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client*
path: wazuh-cert-oauth2-client-${{ matrix.target }}

build-macos:
name: Build CLI for macOS
Expand Down Expand Up @@ -94,11 +97,14 @@ jobs:
run: cargo build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client

- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client wazuh-cert-oauth2-client-${{ matrix.target }}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client*
path: wazuh-cert-oauth2-client-${{ matrix.target }}

build-windows:
name: Build CLI for Windows
Expand Down Expand Up @@ -138,11 +144,14 @@ jobs:
run: cargo build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client

- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client.exe wazuh-cert-oauth2-client-${{ matrix.target }}.exe

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client*
path: wazuh-cert-oauth2-client-${{ matrix.target }}.exe

release:
name: Release
Expand Down
8 changes: 4 additions & 4 deletions helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "wazuh-cert-oauth2.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "wazuh-cert-oauth2.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wazuh-cert-oauth2.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "common.names.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wazuh-cert-oauth2.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.names.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
Expand Down
15 changes: 15 additions & 0 deletions helm/templates/_annotations.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{/*
Common annoations
*/}}
{{- define "common.annotations.standard" -}}
{{- $result := dict -}}
{{- if and (hasKey . "customAnnotations") (hasKey . "context") -}}
{{- $result = (include "common.tplvalues.merge" (dict "values" (list .customAnnotations .context.Values.commonAnnotations) "context" .context)) -}}
{{- else if and $.Values $.Values.commonAnnotations -}}
{{- $result = include "common.tplvalues.render" (dict "value" $.Values.commonAnnotations "context" $) -}}
{{- end -}}

{{- if gt (len $result) 2 -}}
{{ $result }}
{{- end -}}
{{- end -}}
62 changes: 0 additions & 62 deletions helm/templates/_helpers.tpl

This file was deleted.

75 changes: 37 additions & 38 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,71 @@
{{ with .Values }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "wazuh-cert-oauth2.fullname" . }}
name: {{ include "common.names.fullname" $ }}
namespace: {{ include "common.names.namespace" $ }}
labels:
{{- include "wazuh-cert-oauth2.labels" . | nindent 4 }}
{{- include "common.labels.standard" ( dict "customLabels" .commonLabels "context" $ ) | nindent 4 }}
annotations:
{{- include "common.annotations.standard" ( dict "customAnnotations" .commonAnnotations "context" $ ) | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- if not .autoscaling.enabled }}
replicas: {{ .replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "wazuh-cert-oauth2.selectorLabels" . | nindent 6 }}
{{ include "common.labels.matchLabels" ( dict "customLabels" .podLabels "context" $ ) | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
{{- with .podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "wazuh-cert-oauth2.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{ include "common.labels.standard" ( dict "customLabels" .podLabels "context" $ ) | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "wazuh-cert-oauth2.serviceAccountName" . }}
serviceAccountName: {{ include "common.names.fullname" $ }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ include "common.names.name" $ }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
{{- toYaml .securityContext | nindent 12 }}
{{ $imageTpl := include "common.images.image" (dict "imageRoot" .image "global" $.Values.global) }}
image: {{ include "common.tplvalues.render" (dict "value" $imageTpl "context" $) | quote }}
{{ with .resources -}}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- end }}
{{- with .Values.env }}
{{ with .volumeMounts -}}
volumeMounts: {{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12}}
{{- end }}
{{ with .ports -}}
ports: {{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12}}
{{- end }}
{{ with .env -}}
env:
{{- toYaml . | nindent 12 }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12}}
{{- end }}
{{ with .envFrom -}}
envFrom:
{{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12}}
{{- end }}
{{- with .Values.volumes }}
{{- with .volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

{{ end }}
9 changes: 6 additions & 3 deletions helm/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "wazuh-cert-oauth2.fullname" . }}
name: {{ include "common.names.fullname" $ }}
namespace: {{ include "common.names.namespace" $ }}
annotations:
{{- include "common.annotations.standard" ( dict "customAnnotations" (merge dict $.Values.commonIngressAnnotations .annotations) "context" $ ) | nindent 4 }}
labels:
{{- include "wazuh-cert-oauth2.labels" . | nindent 4 }}
{{- include "common.labels.standard" ( dict "customLabels" .additionalLabels "context" $ ) | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "wazuh-cert-oauth2.fullname" . }}
name: {{ include "common.names.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
70 changes: 21 additions & 49 deletions helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,33 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "wazuh-cert-oauth2.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
{{- if and (.Values.ingress.enabled) (eq .Values.service.type "ClusterIP") }}
{{- with .Values.ingress -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "wazuh-cert-oauth2.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
name: {{ include "common.names.fullname" $ }}
namespace: {{ include "common.names.namespace" $ }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "common.annotations.standard" ( dict "customAnnotations" (merge dict $.Values.commonIngressAnnotations .annotations) "context" $ ) | nindent 4 }}
labels:
{{- include "common.labels.standard" ( dict "customLabels" .additionalLabels "context" $ ) | nindent 4 }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{ with .className -}}
ingressClassName: {{ . }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
- host: {{ include "common.tplvalues.render" (dict "value" .host "context" $) }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
- path: /
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
name: {{ include "common.names.fullname" $ }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
number: {{ include "common.tplvalues.render" (dict "value" $.Values.service.port "context" $) }}
{{ with .tls }}
tls:
- hosts:
- {{ include "common.tplvalues.render" (dict "value" .host "context" $) }}
{{ end }}
{{- end -}}
{{- end }}
17 changes: 12 additions & 5 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{{ with .Values.service }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "wazuh-cert-oauth2.fullname" . }}
name: {{ include "common.names.fullname" $ }}
namespace: {{ include "common.names.namespace" $ }}
labels:
{{- include "wazuh-cert-oauth2.labels" . | nindent 4 }}
{{- include "common.labels.standard" ( dict "customLabels" .additionalLabels "context" $ ) | nindent 4 }}
annotations:
{{- include "common.annotations.standard" ( dict "customAnnotations" .additionalAnnotations "context" $ ) | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{ with .type }}
type: {{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{ end }}
ports:
- port: {{ .Values.service.port }}
- port: {{ include "common.tplvalues.render" (dict "value" .port "context" $) }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "wazuh-cert-oauth2.selectorLabels" . | nindent 4 }}
{{- include "common.labels.matchLabels" ( dict "customLabels" .additionalLabels "context" $ ) | nindent 4 }}
{{ end }}
Loading

0 comments on commit 2438d15

Please sign in to comment.