-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #724 from Rakshithb1/MOSIP-30647
[MOSIP-30647] added info helm chart
- Loading branch information
Showing
13 changed files
with
417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
charts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v2 | ||
name: info | ||
description: A Helm chart to get deployment information | ||
type: application | ||
version: 0.0.1-develop | ||
appVersion: "" | ||
home: https://mosip.io | ||
keywords: | ||
- mosip | ||
- info | ||
maintainers: | ||
- email: [email protected] | ||
name: MOSIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Info Helm Chart | ||
|
||
This Helm chart deploys an NGINX server along with a script to fetch Namespace, Image, helm chart version and Image ID from k8s cluster. | ||
|
||
## TL;DR | ||
|
||
```console | ||
$ helm repo add mosip https://mosip.github.io | ||
$ helm install my-release mosip/info | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "info.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 "info.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 "info.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "info.labels" -}} | ||
helm.sh/chart: {{ include "info.chart" . }} | ||
{{ include "info.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "info.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "info.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "info.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "info.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Render tpl values. | ||
*/}} | ||
{{- define "common.tplvalues.render" -}} | ||
{{- $value := .value -}} | ||
{{- $context := .context -}} | ||
{{- tpl (toYaml $value) $context -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- namespaces | ||
- pods | ||
verbs: | ||
- get | ||
- list | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- deployments | ||
- statefulsets | ||
verbs: | ||
- get | ||
- list | ||
- apiGroups: | ||
- batch | ||
resources: | ||
- jobs | ||
- cronjobs | ||
verbs: | ||
- get | ||
- list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ .Release.Name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ .Release.Name }} | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Release.Name }}-script-config | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
fetch-info.sh: | | ||
#!/bin/sh | ||
EXCLUDED_NAMESPACE='^(istio|cattle|kube|info)' | ||
OUTPUT_DIR=/usr/share/nginx/html/info/info.txt | ||
# Clear existing info.txt or create if not exists | ||
> $OUTPUT_DIR | ||
kubectl get namespaces | awk 'NR>1 {print $1}' | grep -vE $EXCLUDED_NAMESPACE | while read namespace; do | ||
echo "Namespace: $namespace" >> $OUTPUT_DIR | ||
echo "----------------" >> $OUTPUT_DIR | ||
# Get deployments | ||
kubectl get deployments -n $namespace -o json | jq -r '.items[] | "Deployment: \(.metadata.name), Image: \(.spec.template.spec.containers[].image), Helm Chart Version: \(.metadata.labels["helm.sh/chart"])"' >> $OUTPUT_DIR | ||
# Get statefulsets | ||
kubectl get statefulsets -n $namespace -o json | jq -r '.items[] | "StatefulSet: \(.metadata.name), Image: \(.spec.template.spec.containers[].image), Helm Chart Version: \(.metadata.labels["helm.sh/chart"])"' >> $OUTPUT_DIR | ||
# Get cronjobs | ||
kubectl get cronjobs -n $namespace -o json | jq -r '.items[] | "CronJob: \(.metadata.name), Image: \(.spec.jobTemplate.spec.template.spec.containers[].image), Helm Chart Version: \(.metadata.labels["helm.sh/chart"])"' >> $OUTPUT_DIR | ||
# Get jobs | ||
kubectl get jobs -n $namespace -o json | jq -r '.items[] | "Job: \(.metadata.name), Image: \(.spec.template.spec.containers[].image), Helm Chart Version: \(.metadata.labels["helm.sh/chart"])"' >> $OUTPUT_DIR | ||
kubectl get pods -n $namespace -o json | jq -r '.items[] | .status.containerStatuses[] | select(.imageID | contains("istio") | not) | "ImageID: \(.imageID | sub("docker-pullable://"; ""))"' >> $OUTPUT_DIR | ||
echo "" >> $OUTPUT_DIR | ||
done | ||
echo "Script executed at $(date)" >> $OUTPUT_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "info.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
app: info | ||
template: | ||
metadata: | ||
labels: | ||
app: info | ||
spec: | ||
serviceAccountName: {{ .Release.Name }} | ||
containers: | ||
- name: nginx | ||
image: {{ .Values.nginx.image }} | ||
imagePullPolicy: {{ .Values.nginx.imagePullPolicy }} | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: result-file | ||
mountPath: /usr/share/nginx/html/info | ||
subPath: info.txt | ||
{{- if .Values.resources }} | ||
resources: {{- toYaml .Values.resources | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.startupProbe.enabled }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customStartupProbe }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.livenessProbe.enabled }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customLivenessProbe }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.readinessProbe.enabled }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customReadinessProbe }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.sidecars }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} | ||
{{- end }} | ||
- name: script-runner | ||
image: {{ .Values.scriptRunner.image }} | ||
imagePullPolicy: {{ .Values.nginx.imagePullPolicy }} | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
apk add --no-cache bash curl bind-tools jq | ||
curl -LO "https://dl.k8s.io/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin/ | ||
cp /fetch-info.sh /tmp/fetch-info.sh | ||
chmod +x /tmp/fetch-info.sh | ||
/tmp/fetch-info.sh | ||
echo "0 2 * * * /tmp/fetch-info.sh" > /etc/crontabs/root | ||
crond -f | ||
volumeMounts: | ||
- name: script-file | ||
mountPath: /fetch-info.sh | ||
subPath: fetch-info.sh | ||
- name: result-file | ||
mountPath: /usr/share/nginx/html/info | ||
subPath: info.txt | ||
{{- if .Values.resources }} | ||
resources: {{- toYaml .Values.resources | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.startupProbe.enabled }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customStartupProbe }} | ||
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.livenessProbe.enabled }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customLivenessProbe }} | ||
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.readinessProbe.enabled }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }} | ||
{{- else if .Values.customReadinessProbe }} | ||
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.sidecars }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} | ||
{{- end }} | ||
volumes: | ||
- name: script-file | ||
configMap: | ||
name: {{ .Release.Name }}-script-config | ||
- name: result-file | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
selector: | ||
app: info | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
type: ClusterIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: VirtualService | ||
metadata: | ||
name: {{ .Release.Name }} | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
hosts: | ||
- "*" | ||
gateways: | ||
{{- if .Values.istio.gateways }} | ||
{{- range .Values.istio.gateways }} | ||
- {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
http: | ||
- match: | ||
- uri: | ||
prefix: {{ .Values.istio.prefix }} | ||
rewrite: | ||
uri: {{ .Values.istio.rewrite }} | ||
route: | ||
- destination: | ||
host: {{ .Release.Name }} | ||
port: | ||
number: 80 | ||
headers: | ||
request: | ||
set: | ||
x-forwarded-proto: https |
Oops, something went wrong.