Skip to content

Commit 995772b

Browse files
committed
helm and storage added
1 parent b802b42 commit 995772b

File tree

95 files changed

+5142
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5142
-0
lines changed

kube/helm/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Helm, The Kubernetes package manager
2+
3+
> `Helm` helps you manage Kubernetes applications with `Helm Charts` which helps you define, install, and upgrade even the most complex Kubernetes application.
4+
5+
> The main building block of Helm based deployments are Helm Charts: these charts describe a configurable set of dynamically generated Kubernetes resources.
6+
7+
> The charts can either be stored locally or fetched from remote chart repositories.
8+
9+
## The Basic Architecture / Helm Version 3
10+
11+
> Helm 3 is a single-service architecture. One executable is responsible for implementing Helm. There is no client/server split, nor is the core processing logic distributed among components.
12+
13+
> Implementation of Helm 3 is a single command-line client with no in-cluster server or controller. This tool exposes command-line operations, and unilaterally handles the package management process.
14+
15+
### ***The implementation has two distinct parts:***
16+
17+
1. The command line façade, which translates commands, subcommands, flags, and arguments into a Helm operation
18+
2. The Helm library, which provides the logic for executing all Helm operations.
19+
20+
### **By design, the Helm library must be usable as a standalone library.**
21+
22+
## some key words to understand in helm
23+
24+
### Chart
25+
A Chart is a Helm package. It contains all of the resource definitions necessary to run an application, tool, or service inside of a Kubernetes cluster. Think of it like the Kubernetes equivalent of a Homebrew formula, an Apt dpkg, or a Yum RPM file.
26+
27+
### Repository
28+
A Repository is the place where charts can be collected and shared. It’s like Perl’s CPAN archive or the Fedora Package Database, but for Kubernetes packages.
29+
30+
### Release
31+
A Release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster. And each time it is installed, a new release is created. Consider a MySQL chart. If you want two databases running in your cluster, you can install that chart twice. Each one will have its own release, which will in turn have its own release name.
32+
33+
34+
## Client Only Architecture
35+
36+
> Helm 3 has a client-only architecture with the client still called helm. As seen in the following diagram, it operates similar to the Helm 2 client, but the client interacts directly with the Kubernetes API server. The in-cluster server Tiller is now removed.
37+
38+
![helm3-architecture](https://github.com/lerndevops/static/blob/master/kube/helm3-architecture.PNG)
39+
40+
41+
## Install Helm version3
42+
43+
```
44+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
45+
chmod 700 get_helm.sh
46+
./get_helm.sh
47+
```
48+
```
49+
root@kube-master:~# helm version --short
50+
v3.0.2+g19e47ee
51+
```
52+
53+
#### Common actions for Helm:
54+
55+
```
56+
- helm search: search for charts (helm search hub awx)
57+
- helm pull: download a chart to your local directory to view
58+
- helm install: upload the chart to Kubernetes
59+
- helm list: list releases of charts
60+
```
61+
62+
### other helm commands
63+
64+
```
65+
completion Generate autocompletions script for the specified shell (bash or zsh)
66+
create create a new chart with the given name
67+
dependency manage a chart's dependencies
68+
env Helm client environment information
69+
get download extended information of a named release
70+
help Help about any command
71+
history fetch release history
72+
install install a chart
73+
lint examines a chart for possible issues
74+
list list releases
75+
package package a chart directory into a chart archive
76+
plugin install, list, or uninstall Helm plugins
77+
pull download a chart from a repository and (optionally) unpack it in local directory
78+
repo add, list, remove, update, and index chart repositories
79+
rollback roll back a release to a previous revision
80+
search search for a keyword in charts
81+
show show information of a chart
82+
status displays the status of the named release
83+
template locally render templates
84+
test run tests for a release
85+
uninstall uninstall a release
86+
upgrade upgrade a release
87+
verify verify that a chart at the given path has been signed and is valid
88+
```

kube/helm/awx-helm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# works with GKE
2+
3+
helm search hub awx
4+
helm pull hub adwerx/awx
5+
helm pull https://hub.helm.sh/charts/adwerx/awx
6+
helm install https://hub.helm.sh/charts/adwerx/awx
7+
helm install adwerx/awx
8+
helm list
9+
helm repo add adwerx https://adwerx.github.io/charts
10+
helm list
11+
helm install adwerx/awx
12+
helm install adwerx/awx --version 2.2.1
13+
helm install adwerx/awx --version 2.2.1 --generate-name
14+
helm list
15+
kubectl get pods
16+
kubectl get svc
17+
18+
# edit the service awx-1587279178 with type NodePort
19+
kubectl get svc # note the NodePort and access the app with Node IP

kube/helm/charts/grafana/Chart.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: grafana
2+
version: 1.8.0
3+
appVersion: 5.0.4
4+
description: The leading tool for querying and visualizing time series and metrics.
5+
home: https://grafana.net
6+
icon: https://raw.githubusercontent.com/grafana/grafana/master/public/img/logo_transparent_400x.png
7+
sources:
8+
- https://github.com/grafana/grafana
9+
maintainers:
10+
- name: Ming Hsieh
11+
12+
- name: rtluckie
13+
14+
engine: gotpl

kube/helm/charts/grafana/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Grafana Helm Chart
2+
3+
* Installs the web dashboarding system [Grafana](http://grafana.org/)
4+
5+
## TL;DR;
6+
7+
```console
8+
$ helm install stable/grafana
9+
```
10+
11+
## Installing the Chart
12+
13+
To install the chart with the release name `my-release`:
14+
15+
```console
16+
$ helm install --name my-release stable/grafana
17+
```
18+
19+
## Uninstalling the Chart
20+
21+
To uninstall/delete the my-release deployment:
22+
23+
```console
24+
$ helm delete my-release
25+
```
26+
27+
The command removes all the Kubernetes components associated with the chart and deletes the release.
28+
29+
30+
## Configuration
31+
32+
33+
| Parameter | Description | Default |
34+
|----------------------------|-------------------------------------|---------------------------------------------------------|
35+
| `replicas` | Number of nodes | `1` |
36+
| `deploymentStrategy` | Deployment strategy | `RollingUpdate` |
37+
| `image.repository` | Image repository | `grafana/grafana` |
38+
| `image.tag` | Image tag. (`Must be >= 5.0.0`) Possible values listed [here](https://hub.docker.com/r/grafana/grafana/tags/).| `5.0.4`|
39+
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
40+
| `service.type` | Kubernetes service type | `ClusterIP` |
41+
| `service.port` | Kubernetes port where service is exposed| `9000` |
42+
| `service.annotations` | Service annotations | `80` |
43+
| `service.labels` | Custom labels | `{}`
44+
| `ingress.enabled` | Enables Ingress | `false` |
45+
| `ingress.annotations` | Ingress annotations | `{}` |
46+
| `ingress.labels` | Custom labels | `{}`
47+
| `ingress.hosts` | Ingress accepted hostnames | `[]` |
48+
| `ingress.tls` | Ingress TLS configuration | `[]` |
49+
| `resources` | CPU/Memory resource requests/limits | `{}` |
50+
| `nodeSelector` | Node labels for pod assignment | `{}` |
51+
| `tolerations` | Toleration labels for pod assignment | `[]` |
52+
| `affinity` | Affinity settings for pod assignment | `{}` |
53+
| `persistence.enabled` | Use persistent volume to store data | `false` |
54+
| `persistence.size` | Size of persistent volume claim | `10Gi` |
55+
| `persistence.existingClaim`| Use an existing PVC to persist data | `nil` |
56+
| `persistence.storageClassName` | Type of persistent volume claim | `nil` |
57+
| `persistence.accessModes` | Persistence access modes | `[]` |
58+
| `persistence.subPath` | Mount a sub directory of the persistent volume if set | `""` |
59+
| `schedulerName` | Alternate scheduler name | `nil` |
60+
| `env` | Extra environment variables passed to pods | `{}` |
61+
| `envFromSecret` | The name of a Kubenretes secret (must be manually created in the same namespace) containing values to be added to the environment | `""` |
62+
| `datasource` | Configure grafana datasources | `{}` |
63+
| `dashboardProviders` | Configure grafana dashboard providers | `{}` |
64+
| `dashboards` | Dashboards to import | `{}` |
65+
| `grafana.ini` | Grafana's primary configuration | `{}` |
66+
| `ldap.existingSecret` | The name of an existing secret containing the `ldap.toml` file, this must have the key `ldap-toml`. | `""` |
67+
| `ldap.config ` | Grafana's LDAP configuration | `""` |
68+
| `annotations` | Deployment annotations | `{}` |
69+
| `podAnnotations` | Pod annotations | `{}` |
70+
| `smtp.existingSecret` | The name of an existing secret containing the SMTP credentials, this must have the keys `user` and `password`. | `""` |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
adminPassword: password
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
1. Get your '{{ .Values.adminUser }}' user password by running:
2+
3+
kubectl get secret --namespace {{ .Release.Namespace }} {{ template "grafana.fullname" . }} -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
4+
5+
2. The Grafana server can be accessed via port {{ .Values.service.port }} on the following DNS name from within your cluster:
6+
7+
{{ template "grafana.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
8+
{{ if .Values.ingress.enabled }}
9+
From outside the cluster, the server URL(s) are:
10+
{{- range .Values.ingress.hosts }}
11+
http://{{ . }}
12+
{{- end }}
13+
{{ else }}
14+
Get the Grafana URL to visit by running these commands in the same shell:
15+
{{ if contains "NodePort" .Values.service.type -}}
16+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "grafana.fullname" . }})
17+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
18+
echo http://$NODE_IP:$NODE_PORT
19+
{{ else if contains "LoadBalancer" .Values.service.type -}}
20+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
21+
You can watch the status of by running 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "grafana.fullname" . }}'
22+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "grafana.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
23+
http://$SERVICE_IP:{{ .Values.service.port -}}
24+
{{ else if contains "ClusterIP" .Values.service.type }}
25+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "grafana.fullname" . }},component={{ .Values.name }}" -o jsonpath="{.items[0].metadata.name}")
26+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 3000
27+
{{- end }}
28+
{{- end }}
29+
30+
3. Login with the password from step 1 and the username: {{ .Values.adminUser }}
31+
32+
{{- if not .Values.persistence.enabled }}
33+
#################################################################################
34+
###### WARNING: Persistence is disabled!!! You will lose your data when #####
35+
###### the Grafana pod is terminated. #####
36+
#################################################################################
37+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "grafana.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+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "grafana.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "grafana.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "grafana.fullname" . }}
5+
labels:
6+
app: {{ template "grafana.name" . }}
7+
chart: {{ template "grafana.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
data:
11+
{{- with .Values.plugins }}
12+
plugins: {{ . | quote }}
13+
{{- end }}
14+
grafana.ini: |
15+
{{- range $key, $value := index .Values "grafana.ini" }}
16+
[{{ $key }}]
17+
{{- range $elem, $elemVal := $value }}
18+
{{ $elem }} = {{ $elemVal }}
19+
{{- end }}
20+
{{- end }}
21+
22+
{{- if .Values.datasources }}
23+
{{- range $key, $value := .Values.datasources }}
24+
{{ $key }}: |
25+
{{ toYaml $value | indent 4 }}
26+
{{- end -}}
27+
{{- end -}}
28+
29+
{{- if .Values.dashboardProviders }}
30+
{{- range $key, $value := .Values.dashboardProviders }}
31+
{{ $key }}: |
32+
{{ toYaml $value | indent 4 }}
33+
{{- end -}}
34+
{{- end -}}
35+
36+
{{- if .Values.dashboards }}
37+
download_dashboards.sh: |
38+
#!/usr/bin/env sh
39+
set -euf
40+
mkdir -p /var/lib/grafana/dashboards
41+
{{- range $key, $value := .Values.dashboards }}
42+
{{- if (or (hasKey $value "gnetId") (hasKey $value "url")) }}
43+
curl -sk \
44+
--connect-timeout 60 \
45+
--max-time 60 \
46+
-H "Accept: application/json" \
47+
-H "Content-Type: application/json;charset=UTF-8" \
48+
{{- if $value.url -}}{{ $value.url }}{{- else -}} https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download{{- end -}}{{ if $value.datasource }}| sed 's|\"datasource\":[^,]*|\"datasource\": \"{{ $value.datasource }}\"|g'{{ end }} \
49+
> /var/lib/grafana/dashboards/{{ $key }}.json
50+
{{- end }}
51+
{{- end }}
52+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "grafana.fullname" . }}-dashboards-json
5+
labels:
6+
app: {{ template "grafana.name" . }}
7+
chart: {{ template "grafana.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
data:
11+
{{- if .Values.dashboards }}
12+
{{- range $key, $value := .Values.dashboards }}
13+
{{- if hasKey $value "json" }}
14+
{{ $key }}.json: |
15+
{{ $value.json | indent 4 }}
16+
{{- end }}
17+
{{- end }}
18+
{{- end -}}

0 commit comments

Comments
 (0)