Resolve "Setup installation Scripts in order to simplify deployment in new environments"

Closes #69 (closed)

Merge request reports

Loading
+15 −0
Changes for helm/monitoring-stack/charts/grafana/templates/tests/test-connection.yaml: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "grafana.fullname" . }}-test-connection"
  labels:
    {{- include "grafana.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": test
spec:
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args: ['{{ include "grafana.fullname" . }}:{{ .Values.service.port }}']
  restartPolicy: Never
+22 −0
Changes for helm/monitoring-stack/charts/grafana/templates/NOTES.txt: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
  {{- range .paths }}
  http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
  {{- 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 "grafana.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 "grafana.fullname" . }}'
  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "grafana.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 "grafana.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
{{- end }}
+62 −0
Changes for helm/monitoring-stack/charts/grafana/templates/_helpers.tpl: 62 added lines, 0 removed lines.
Original line number Diff line number Diff line
{{/*
Expand the name of the chart.
*/}}
{{- define "grafana.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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 "grafana.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "grafana.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "grafana.labels" -}}
helm.sh/chart: {{ include "grafana.chart" . }}
{{ include "grafana.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "grafana.selectorLabels" -}}
app.kubernetes.io/name: {{ include "grafana.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "grafana.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "grafana.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
+53 −0
Changes for helm/monitoring-stack/charts/grafana/templates/configmap.yaml: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: v1
kind: ConfigMap
metadata:
  name: datasources
data:
  datasources.yaml: |
    apiVersion: 1 
    datasources:
      - name: Prometheus
        type: prometheus
        typeName: Prometheus
        typeLogoUrl: public/app/plugins/datasource/prometheus/img/prometheus_logo.svg
        access: proxy
        url: {{ .Values.env.prometheusUrl }}
        uid: af6b44aa-0703-4979-825c-c1afba946534
        user: ''
        database: ''
        basicAuth: false
        isDefault: false
        jsonData:
          httpMethod: POST
          prometheusType: Prometheus
          prometheusVersion: 2.40.1
        readOnly: false 
---

apiVersion: v1
kind: ConfigMap
metadata:
  name: default
data:
  default.yaml: |
    apiVersion: 1
    providers:
      - name: Default # A uniquely identifiable name for the provider
        orgId: 1
        folder: "" # The folder where to place the dashboards
        folderUid: ""
        type: file
        disableDeletion: false
        allowUiUpdates: true
        options:
          path: /var/lib/grafana/dashboards

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: kubernetes-dashboard
data:
  kubernetes-dashboard.json: |
{{ .Files.Get "kubernetes-dashboard.json" | indent 4 }}
 No newline at end of file
+102 −0
Changes for helm/monitoring-stack/charts/grafana/templates/deployment.yaml: 102 added lines, 0 removed lines.
Original line number Diff line number Diff line
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "grafana.fullname" . }}
  labels:
    {{- include "grafana.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  strategy:
    type: Recreate
  {{- end }}
  selector:
    matchLabels:
      {{- include "grafana.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
      labels:
        {{- include "grafana.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "grafana.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - env:
            - name: GF_AUTH_ANONYMOUS_ENABLED
              value: {{ quote .Values.env.gfAuthAnonymousEnable }}
            - name: GF_SECURITY_ALLOW_EMBEDDING
              value: {{ quote .Values.env.gfSecurityAllowEmbedding }}
            - name: GF_PATHS_PROVISIONING
              value: /etc/grafana/provisioning
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          name: {{ .Chart.Name }}
          envFrom:
            - secretRef:
                name: grafana-secrets
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
#          livenessProbe:
#            tcpSocket:
#              port: {{ .Values.service.port }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          volumeMounts:
            - name: grafana-datasources
              mountPath: /etc/grafana/provisioning/datasources/datasources.yaml
              subPath: datasources.yaml
            - name: grafana-default
              mountPath: /etc/grafana/provisioning/dashboards/default.yaml
              subPath: default.yaml
            - name: kubernetes-dashboard
              mountPath: /var/lib/grafana/dashboards/kubernetes-dashboard.json
              subPath: kubernetes-dashboard.json
            {{- if .Values.persistence.enable | default false }}
            - name: grafana-claim0
              mountPath: /var/lib/grafana
            {{- end }}
      volumes:
      - name: grafana-datasources
        configMap:
          name: datasources
          items:
          - key: "datasources.yaml"
            path: "datasources.yaml"
      - name: grafana-default
        configMap:
          name: default
          items:
          - key: "default.yaml"
            path: "default.yaml"
      - name: kubernetes-dashboard
        configMap:
          name: kubernetes-dashboard
          items:
          - key: "kubernetes-dashboard.json"
            path: "kubernetes-dashboard.json"
      {{- if .Values.persistence.enable | default false }}
      - name: grafana-claim0
        persistentVolumeClaim:
          claimName: grafana-claim0
      {{- end }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
 No newline at end of file
Loading
Loading