Skip to content

Commit

Permalink
updated charts to reflect deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Rime committed Jan 20, 2023
1 parent cd4cf87 commit 03a9b02
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 111 deletions.
2 changes: 1 addition & 1 deletion charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: charts
name: workspaceone-exporter
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
Expand Down
8 changes: 4 additions & 4 deletions charts/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 "charts.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "workspaceone-exporter.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 the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "charts.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "charts.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "workspaceone-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "workspaceone-exporter.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 "charts.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 "workspaceone-exporter.name" . }},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
31 changes: 21 additions & 10 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "charts.name" -}}
{{- define "workspaceone-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ 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 "charts.fullname" -}}
{{- define "workspaceone-exporter.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "charts.chart" -}}
{{- define "workspaceone-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "charts.labels" -}}
helm.sh/chart: {{ include "charts.chart" . }}
{{ include "charts.selectorLabels" . }}
{{- define "workspaceone-exporter.labels" -}}
helm.sh/chart: {{ include "workspaceone-exporter.chart" . }}
{{ include "workspaceone-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,18 +45,29 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "charts.selectorLabels" -}}
app.kubernetes.io/name: {{ include "charts.name" . }}
{{- define "workspaceone-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "workspaceone-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "charts.serviceAccountName" -}}
{{- define "workspaceone-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "charts.fullname" .) .Values.serviceAccount.name }}
{{- default (include "workspaceone-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "workspaceone-exporter.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
44 changes: 27 additions & 17 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "charts.fullname" . }}
name: {{ include "workspaceone-exporter.fullname" . }}
labels:
{{- include "charts.labels" . | nindent 4 }}
{{- include "workspaceone-exporter.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "charts.selectorLabels" . | nindent 6 }}
{{- include "workspaceone-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "charts.selectorLabels" . | nindent 8 }}
{{- include "workspaceone-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "charts.serviceAccountName" . }}
serviceAccountName: {{ include "workspaceone-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand All @@ -34,22 +34,32 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.envVars }}
- name: {{ .name }}
value: {{ .value }}
{{- end }}
- name: WS1_AUTH_KEY
valueFrom:
secretKeyRef:
name: workspaceone-token-secret
key: ws1UserToken
- name: WS1_TENANT_KEY
valueFrom:
secretKeyRef:
name: workspaceone-token-secret
key: ws1ServerToken
- name: WS1_URL
value: {{ .Values.ws1Url | quote }}
- name: WS1_LGID
value: {{ .Values.ws1Lgid | quote }}
- name: WS1_INTERVAL
value: {{ .Values.ws1Interval | quote }}
- name: TAG_FILTER
value: {{ .Values.ws1TagFilter | quote }}
- name: TAG_PARSING
value: {{ .Values.ws1TagParsing | quote }}
- name: INSECURE
value: {{ .Values.ws1Insecure | quote }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
6 changes: 3 additions & 3 deletions charts/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "charts.fullname" . }}
name: {{ include "workspaceone-exporter.fullname" . }}
labels:
{{- include "charts.labels" . | nindent 4 }}
{{- include "workspaceone-exporter.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "charts.fullname" . }}
name: {{ include "workspaceone-exporter.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
4 changes: 2 additions & 2 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "charts.fullname" . -}}
{{- $fullName := include "workspaceone-exporter.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") }}
Expand All @@ -17,7 +17,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "charts.labels" . | nindent 4 }}
{{- include "workspaceone-exporter.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
9 changes: 9 additions & 0 deletions charts/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: workspaceone-token-secret
type: Opaque
data:
ws1UserToken: {{ .Values.ws1UserToken | quote }}
ws1ServerToken: {{ .Values.ws1ServerToken | quote }}

6 changes: 3 additions & 3 deletions charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "charts.fullname" . }}
name: {{ include "workspaceone-exporter.fullname" . }}
labels:
{{- include "charts.labels" . | nindent 4 }}
{{- include "workspaceone-exporter.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "charts.selectorLabels" . | nindent 4 }}
{{- include "workspaceone-exporter.selectorLabels" . | nindent 4 }}
4 changes: 2 additions & 2 deletions charts/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "charts.serviceAccountName" . }}
name: {{ include "workspaceone-exporter.serviceAccountName" . }}
labels:
{{- include "charts.labels" . | nindent 4 }}
{{- include "workspaceone-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
45 changes: 9 additions & 36 deletions charts/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,15 @@
{{- if and .Values.prometheus.enabled .Values.prometheus.serviceMonitor.selfMonitor }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "kube-prometheus-stack.fullname" . }}-prometheus
namespace: {{ template "kube-prometheus-stack.namespace" . }}
labels:
app: {{ template "kube-prometheus-stack.name" . }}-prometheus
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
name: workspaceone-exporter
spec:
selector:
matchLabels:
app: {{ template "kube-prometheus-stack.name" . }}-prometheus
release: {{ $.Release.Name | quote }}
self-monitor: "true"
endpoints:
- honorLabels: true
port: http
jobLabel: workspaceone-exporter
namespaceSelector:
matchNames:
- {{ printf "%s" (include "kube-prometheus-stack.namespace" .) | quote }}
endpoints:
- port: {{ .Values.prometheus.prometheusSpec.portName }}
{{- if .Values.prometheus.serviceMonitor.interval }}
interval: {{ .Values.prometheus.serviceMonitor.interval }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.scheme }}
scheme: {{ .Values.prometheus.serviceMonitor.scheme }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.tlsConfig }}
tlsConfig: {{ toYaml .Values.prometheus.serviceMonitor.tlsConfig | nindent 6 }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.bearerTokenFile }}
bearerTokenFile: {{ .Values.prometheus.serviceMonitor.bearerTokenFile }}
{{- end }}
path: "{{ trimSuffix "/" .Values.prometheus.prometheusSpec.routePrefix }}/metrics"
{{- if .Values.prometheus.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ tpl (toYaml .Values.prometheus.serviceMonitor.metricRelabelings | indent 6) . }}
{{- end }}
{{- if .Values.prometheus.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.prometheus.serviceMonitor.relabelings | indent 6 }}
{{- end }}
{{- end }}
- {{ template "workspaceone-exporter.namespace" . }}
selector:
matchLabels:
app.kubernetes.io/name: workspaceone-exporter
15 changes: 0 additions & 15 deletions charts/templates/tests/test-connection.yaml

This file was deleted.

28 changes: 10 additions & 18 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,19 @@

replicaCount: 1

envVars:
- name: WS1_AUTH_KEY
value: myAuthKey
- name: WS1_TENANT_KEY
value: myTenantKey
- name: WS1_URL
value: myUrl
- name: WS1_TENANT_NAME
value: myTenantName
- name: WS1_LGID
value: myLgid
- name: WS1_INTERVAL
value: myInterval
- name: TAG_FILTER
value: myTagFilter
ws1ServerToken: "" # base64 of "Basic " + base64 of "username:password"
ws1UserToken: "" # base64 of the workspaceone server token
ws1Url: ""
ws1Lgid: ""
ws1Interval: ""
ws1TagFilter: ""
ws1TagParsing: ""
ws1Insecure: ""

image:
repository: ghcr.io/christopherime/workspaceone-exporter
repository: "ghcr.io/christopherime/workspaceone-exporter"
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
tag: "latest"

imagePullSecrets: []
nameOverride: ""
Expand Down

0 comments on commit 03a9b02

Please sign in to comment.