Skip to content

Commit f9dbdd1

Browse files
committed
add more helm ops
1 parent 5e3842b commit f9dbdd1

15 files changed

+301
-14
lines changed

helloworld-0.1.0.tgz

2.67 KB
Binary file not shown.
File renamed without changes.

helloworld/Chart.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: helloworld
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
version: 0.1.0
18+
19+
# This is the version number of the application being deployed. This version number should be
20+
# incremented each time you make changes to the application.
21+
appVersion: 1.16.0

helloworld/templates/NOTES.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "helloworld.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "helloworld.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "helloworld.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helloworld.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl port-forward $POD_NAME 8080:80
21+
{{- end }}

helloworld/templates/_helpers.tpl

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "helloworld.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 "helloworld.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 "helloworld.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "helloworld.labels" -}}
38+
helm.sh/chart: {{ include "helloworld.chart" . }}
39+
{{ include "helloworld.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "helloworld.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "helloworld.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "helloworld.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create -}}
59+
{{ default (include "helloworld.fullname" .) .Values.serviceAccount.name }}
60+
{{- else -}}
61+
{{ default "default" .Values.serviceAccount.name }}
62+
{{- end -}}
63+
{{- end -}}

helloworld/templates/deployment.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "helloworld.fullname" . }}
5+
labels:
6+
{{- include "helloworld.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "helloworld.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
labels:
15+
{{- include "helloworld.selectorLabels" . | nindent 8 }}
16+
spec:
17+
{{- with .Values.imagePullSecrets }}
18+
imagePullSecrets:
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
serviceAccountName: {{ include "helloworld.serviceAccountName" . }}
22+
securityContext:
23+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
24+
containers:
25+
- name: {{ .Chart.Name }}
26+
securityContext:
27+
{{- toYaml .Values.securityContext | nindent 12 }}
28+
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
29+
imagePullPolicy: {{ .Values.image.pullPolicy }}
30+
ports:
31+
- name: http
32+
containerPort: 80
33+
protocol: TCP
34+
livenessProbe:
35+
httpGet:
36+
path: /
37+
port: http
38+
readinessProbe:
39+
httpGet:
40+
path: /
41+
port: http
42+
resources:
43+
{{- toYaml .Values.resources | nindent 12 }}
44+
{{- with .Values.nodeSelector }}
45+
nodeSelector:
46+
{{- toYaml . | nindent 8 }}
47+
{{- end }}
48+
{{- with .Values.affinity }}
49+
affinity:
50+
{{- toYaml . | nindent 8 }}
51+
{{- end }}
52+
{{- with .Values.tolerations }}
53+
tolerations:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}

helloworld/templates/ingress.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "helloworld.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: networking.k8s.io/v1beta1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
{{- include "helloworld.labels" . | nindent 4 }}
10+
{{- with .Values.ingress.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
{{- if .Values.ingress.tls }}
16+
tls:
17+
{{- range .Values.ingress.tls }}
18+
- hosts:
19+
{{- range .hosts }}
20+
- {{ . | quote }}
21+
{{- end }}
22+
secretName: {{ .secretName }}
23+
{{- end }}
24+
{{- end }}
25+
rules:
26+
{{- range .Values.ingress.hosts }}
27+
- host: {{ .host | quote }}
28+
http:
29+
paths:
30+
{{- range .paths }}
31+
- path: {{ . }}
32+
backend:
33+
serviceName: {{ $fullName }}
34+
servicePort: {{ $svcPort }}
35+
{{- end }}
36+
{{- end }}
37+
{{- end }}

helloworld/templates/service.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "helloworld.fullname" . }}
5+
labels:
6+
{{- include "helloworld.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "helloworld.selectorLabels" . | nindent 4 }}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "helloworld.serviceAccountName" . }}
6+
labels:
7+
{{ include "helloworld.labels" . | nindent 4 }}
8+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "helloworld.fullname" . }}-test-connection"
5+
labels:
6+
{{ include "helloworld.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": test-success
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "helloworld.fullname" . }}:{{ .Values.service.port }}']
15+
restartPolicy: Never

mychart/values.yaml renamed to helloworld/values.yaml

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
# Default values for mychart.
1+
# Default values for helloworld.
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

55
replicaCount: 1
66

77
image:
88
repository: nginx
9-
tag: stable
109
pullPolicy: IfNotPresent
1110

1211
imagePullSecrets: []
1312
nameOverride: ""
1413
fullnameOverride: ""
1514

15+
serviceAccount:
16+
# Specifies whether a service account should be created
17+
create: true
18+
# The name of the service account to use.
19+
# If not set and create is true, a name is generated using the fullname template
20+
name:
21+
22+
podSecurityContext: {}
23+
# fsGroup: 2000
24+
25+
securityContext: {}
26+
# capabilities:
27+
# drop:
28+
# - ALL
29+
# readOnlyRootFilesystem: true
30+
# runAsNonRoot: true
31+
# runAsUser: 1000
32+
1633
service:
1734
type: ClusterIP
1835
port: 80
@@ -25,7 +42,6 @@ ingress:
2542
hosts:
2643
- host: chart-example.local
2744
paths: []
28-
2945
tls: []
3046
# - secretName: chart-example-tls
3147
# hosts:

helm.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# add a repo
2+
```
3+
helm repo add stale http://mirror.azure.cn/kubernetes/charts/
4+
```
5+
# check repo list
6+
```
7+
helm repo list
8+
```
9+
search repo
10+
```
11+
helm search repo
12+
```
13+
# check versions of a chart
14+
```
15+
helm search repo mysql --versions
16+
```
17+
# create a helm chart
18+
```
19+
helm create helloworld
20+
```
21+
# install the chart
22+
```
23+
helm install hellow helloworld
24+
```
25+
# check helm installed packages/releases
26+
```
27+
helm list
28+
kubectl get secret
29+
helm upgrade hellow helloworld
30+
```
31+
# unstall a release
32+
```
33+
helm uninstall hellow
34+
```
35+
# release a package
36+
```
37+
helm package helloworld
38+
```
39+
# push to docker registry
40+
```
41+
helm chart save helloworld docker.io/mfanjie/helmcharts
42+
```
43+

mychart/Chart.yaml

-5
This file was deleted.

mychart/templates/configmap.yaml

-6
This file was deleted.

readme.MD

+4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ minikube start \
2020
```
2121
# Istio Setup
2222
# install helm 3 (must be 3.x which does not need tiller)
23+
```
2324
https://github.com/helm/helm/releases
25+
```
2426
# install istio
2527
```
2628
git clone https://github.com/istio/istio.git
@@ -34,6 +36,8 @@ set
3436
```
3537
hub: docker.io/istio
3638
tag: 1.3.3
39+
cpu: 1m
40+
memory: 1Mi
3741
```
3842
```
3943
kubectl create ns istio-system

0 commit comments

Comments
 (0)