Skip to content

Commit bfba430

Browse files
authored
Migrate helm chart from archived helm charts repo. (#241)
* Migrate helm chart from archived helm charts repo. Add github action which generates helm chart releases. Signed-off-by: Adam Hamsik <adam.hamsik@lablabs.io> * Add helm chart repository documentation Signed-off-by: Adam Hamsik <adam.hamsik@lablabs.io>
1 parent af7e7e1 commit bfba430

25 files changed

+1386
-0
lines changed

.github/workflows/lint-test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint and Test Charts
2+
3+
on: pull_request
4+
5+
jobs:
6+
lint-test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
14+
- name: Run chart-testing (lint)
15+
id: lint
16+
uses: helm/chart-testing-action@v1.1.0
17+
with:
18+
command: lint
19+
config: ct.yaml
20+
21+
- name: Create kind cluster
22+
uses: helm/kind-action@v1.0.0
23+
if: steps.lint.outputs.changed == 'true'
24+
25+
- name: Run chart-testing (install)
26+
uses: helm/chart-testing-action@v1.1.0
27+
with:
28+
command: install
29+
config: ct.yaml

.github/workflows/release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Configure Git
18+
run: |
19+
git config user.name "$GITHUB_ACTOR"
20+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
21+
22+
- name: Install Helm
23+
run: |
24+
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
25+
chmod 700 get_helm.sh
26+
./get_helm.sh
27+
28+
- name: Add dependency chart repos
29+
run: |
30+
helm repo add stable https://charts.helm.sh/stable
31+
helm repo add incubator https://charts.helm.sh/incubator
32+
33+
- name: Run chart-releaser
34+
uses: helm/chart-releaser-action@v1.0.0
35+
# with:
36+
# charts_dir: kubernetes/charts/coredns
37+
env:
38+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ To install:
1717

1818
This installs the coredns binary in /usr/bin, adds a coredns user (homedir set to /var/lib/coredns)
1919
and a small Corefile /etc/coredns.
20+
21+
# Kuebernetes
22+
23+
## Helm Chart
24+
25+
This repository provides helm chart repo.
26+
27+
```
28+
helm repo add coredns https://coredns.github.io/deployment/
29+
helm install coredns/coredns
30+
```

charts/coredns/.helmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
OWNERS

charts/coredns/Chart.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v2
2+
name: coredns
3+
version: 1.14.0
4+
appVersion: 1.8.0
5+
home: https://coredns.io
6+
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
7+
description: CoreDNS is a DNS server that chains plugins and provides Kubernetes DNS Services
8+
keywords:
9+
- coredns
10+
- dns
11+
- kubedns
12+
sources:
13+
- https://github.com/coredns/coredns
14+
maintainers:
15+
- name: haad
16+
engine: gotpl
17+
type: application
18+
annotations:
19+
artifacthub.io/changes: |
20+
- Initial helm chart changelog

charts/coredns/README.md

Lines changed: 164 additions & 0 deletions
Large diffs are not rendered by default.

charts/coredns/templates/NOTES.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- if .Values.isClusterService }}
2+
CoreDNS is now running in the cluster as a cluster-service.
3+
{{- else }}
4+
CoreDNS is now running in the cluster.
5+
It can be accessed using the below endpoint
6+
{{- if contains "NodePort" .Values.serviceType }}
7+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "coredns.fullname" . }})
8+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
9+
echo "$NODE_IP:$NODE_PORT"
10+
{{- else if contains "LoadBalancer" .Values.serviceType }}
11+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
12+
You can watch the status by running 'kubectl get svc -w {{ template "coredns.fullname" . }}'
13+
14+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "coredns.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
15+
echo $SERVICE_IP
16+
{{- else if contains "ClusterIP" .Values.serviceType }}
17+
"{{ template "coredns.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local"
18+
from within the cluster
19+
{{- end }}
20+
{{- end }}
21+
22+
It can be tested with the following:
23+
24+
1. Launch a Pod with DNS tools:
25+
26+
kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools
27+
28+
2. Query the DNS server:
29+
30+
/ # host kubernetes
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "coredns.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "coredns.fullname" -}}
14+
{{- if .Values.fullnameOverride -}}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
16+
{{- else -}}
17+
{{- $name := default .Chart.Name .Values.nameOverride -}}
18+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
19+
{{- end -}}
20+
{{- end -}}
21+
22+
{{/*
23+
Generate the list of ports automatically from the server definitions
24+
*/}}
25+
{{- define "coredns.servicePorts" -}}
26+
{{/* Set ports to be an empty dict */}}
27+
{{- $ports := dict -}}
28+
{{/* Iterate through each of the server blocks */}}
29+
{{- range .Values.servers -}}
30+
{{/* Capture port to avoid scoping awkwardness */}}
31+
{{- $port := toString .port -}}
32+
33+
{{/* If none of the server blocks has mentioned this port yet take note of it */}}
34+
{{- if not (hasKey $ports $port) -}}
35+
{{- $ports := set $ports $port (dict "istcp" false "isudp" false) -}}
36+
{{- end -}}
37+
{{/* Retrieve the inner dict that holds the protocols for a given port */}}
38+
{{- $innerdict := index $ports $port -}}
39+
40+
{{/*
41+
Look at each of the zones and check which protocol they serve
42+
At the moment the following are supported by CoreDNS:
43+
UDP: dns://
44+
TCP: tls://, grpc://
45+
*/}}
46+
{{- range .zones -}}
47+
{{- if has (default "" .scheme) (list "dns://") -}}
48+
{{/* Optionally enable tcp for this service as well */}}
49+
{{- if eq (default false .use_tcp) true }}
50+
{{- $innerdict := set $innerdict "istcp" true -}}
51+
{{- end }}
52+
{{- $innerdict := set $innerdict "isudp" true -}}
53+
{{- end -}}
54+
55+
{{- if has (default "" .scheme) (list "tls://" "grpc://") -}}
56+
{{- $innerdict := set $innerdict "istcp" true -}}
57+
{{- end -}}
58+
{{- end -}}
59+
60+
{{/* If none of the zones specify scheme, default to dns:// on both tcp & udp */}}
61+
{{- if and (not (index $innerdict "istcp")) (not (index $innerdict "isudp")) -}}
62+
{{- $innerdict := set $innerdict "isudp" true -}}
63+
{{- $innerdict := set $innerdict "istcp" true -}}
64+
{{- end -}}
65+
66+
{{/* Write the dict back into the outer dict */}}
67+
{{- $ports := set $ports $port $innerdict -}}
68+
{{- end -}}
69+
70+
{{/* Write out the ports according to the info collected above */}}
71+
{{- range $port, $innerdict := $ports -}}
72+
{{- if index $innerdict "isudp" -}}
73+
{{- printf "- {port: %v, protocol: UDP, name: udp-%s}\n" $port $port -}}
74+
{{- end -}}
75+
{{- if index $innerdict "istcp" -}}
76+
{{- printf "- {port: %v, protocol: TCP, name: tcp-%s}\n" $port $port -}}
77+
{{- end -}}
78+
{{- end -}}
79+
{{- end -}}
80+
81+
{{/*
82+
Generate the list of ports automatically from the server definitions
83+
*/}}
84+
{{- define "coredns.containerPorts" -}}
85+
{{/* Set ports to be an empty dict */}}
86+
{{- $ports := dict -}}
87+
{{/* Iterate through each of the server blocks */}}
88+
{{- range .Values.servers -}}
89+
{{/* Capture port to avoid scoping awkwardness */}}
90+
{{- $port := toString .port -}}
91+
92+
{{/* If none of the server blocks has mentioned this port yet take note of it */}}
93+
{{- if not (hasKey $ports $port) -}}
94+
{{- $ports := set $ports $port (dict "istcp" false "isudp" false) -}}
95+
{{- end -}}
96+
{{/* Retrieve the inner dict that holds the protocols for a given port */}}
97+
{{- $innerdict := index $ports $port -}}
98+
99+
{{/*
100+
Look at each of the zones and check which protocol they serve
101+
At the moment the following are supported by CoreDNS:
102+
UDP: dns://
103+
TCP: tls://, grpc://
104+
*/}}
105+
{{- range .zones -}}
106+
{{- if has (default "" .scheme) (list "dns://") -}}
107+
{{/* Optionally enable tcp for this service as well */}}
108+
{{- if eq (default false .use_tcp) true }}
109+
{{- $innerdict := set $innerdict "istcp" true -}}
110+
{{- end }}
111+
{{- $innerdict := set $innerdict "isudp" true -}}
112+
{{- end -}}
113+
114+
{{- if has (default "" .scheme) (list "tls://" "grpc://") -}}
115+
{{- $innerdict := set $innerdict "istcp" true -}}
116+
{{- end -}}
117+
{{- end -}}
118+
119+
{{/* If none of the zones specify scheme, default to dns:// on both tcp & udp */}}
120+
{{- if and (not (index $innerdict "istcp")) (not (index $innerdict "isudp")) -}}
121+
{{- $innerdict := set $innerdict "isudp" true -}}
122+
{{- $innerdict := set $innerdict "istcp" true -}}
123+
{{- end -}}
124+
125+
{{/* Write the dict back into the outer dict */}}
126+
{{- $ports := set $ports $port $innerdict -}}
127+
{{- end -}}
128+
129+
{{/* Write out the ports according to the info collected above */}}
130+
{{- range $port, $innerdict := $ports -}}
131+
{{- if index $innerdict "isudp" -}}
132+
{{- printf "- {containerPort: %v, protocol: UDP, name: udp-%s}\n" $port $port -}}
133+
{{- end -}}
134+
{{- if index $innerdict "istcp" -}}
135+
{{- printf "- {containerPort: %v, protocol: TCP, name: tcp-%s}\n" $port $port -}}
136+
{{- end -}}
137+
{{- end -}}
138+
{{- end -}}
139+
140+
{{/*
141+
Create the name of the service account to use
142+
*/}}
143+
{{- define "coredns.serviceAccountName" -}}
144+
{{- if .Values.serviceAccount.create -}}
145+
{{ default (include "coredns.fullname" .) .Values.serviceAccount.name }}
146+
{{- else -}}
147+
{{ default "default" .Values.serviceAccount.name }}
148+
{{- end -}}
149+
{{- end -}}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if and .Values.autoscaler.enabled .Values.rbac.create }}
2+
---
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRole
5+
metadata:
6+
name: {{ template "coredns.fullname" . }}-autoscaler
7+
labels:
8+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
9+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
10+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
11+
{{- if .Values.isClusterService }}
12+
k8s-app: {{ .Chart.Name }}-autoscaler
13+
kubernetes.io/cluster-service: "true"
14+
kubernetes.io/name: "CoreDNS"
15+
{{- end }}
16+
app.kubernetes.io/name: {{ template "coredns.name" . }}-autoscaler
17+
{{- if .Values.customLabels }}
18+
{{ toYaml .Values.customLabels | indent 4 }}
19+
{{- end }}
20+
rules:
21+
- apiGroups: [""]
22+
resources: ["nodes"]
23+
verbs: ["list","watch"]
24+
- apiGroups: [""]
25+
resources: ["replicationcontrollers/scale"]
26+
verbs: ["get", "update"]
27+
- apiGroups: ["extensions", "apps"]
28+
resources: ["deployments/scale", "replicasets/scale"]
29+
verbs: ["get", "update"]
30+
# Remove the configmaps rule once below issue is fixed:
31+
# kubernetes-incubator/cluster-proportional-autoscaler#16
32+
- apiGroups: [""]
33+
resources: ["configmaps"]
34+
verbs: ["get", "create"]
35+
{{- end }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "coredns.fullname" . }}
6+
labels:
7+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
8+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
9+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
10+
{{- if .Values.isClusterService }}
11+
k8s-app: {{ .Chart.Name | quote }}
12+
kubernetes.io/cluster-service: "true"
13+
kubernetes.io/name: "CoreDNS"
14+
{{- end }}
15+
app.kubernetes.io/name: {{ template "coredns.name" . }}
16+
rules:
17+
- apiGroups:
18+
- ""
19+
resources:
20+
- endpoints
21+
- services
22+
- pods
23+
- namespaces
24+
verbs:
25+
- list
26+
- watch
27+
{{- if .Values.rbac.pspEnable }}
28+
- apiGroups:
29+
- policy
30+
- extensions
31+
resources:
32+
- podsecuritypolicies
33+
verbs:
34+
- use
35+
resourceNames:
36+
- {{ template "coredns.fullname" . }}
37+
{{- end }}
38+
{{- end }}

0 commit comments

Comments
 (0)