1) Multipass and k3s
https://andreipope.github.io/tutorials/create-a-cluster-with-multipass-and-k3s.html
➜ k3s git:(main) multipass find --show-unsupported
Image Aliases Version Description
20.04 focal 20240430 Ubuntu 20.04 LTS
22.04 jammy 20240426 Ubuntu 22.04 LTS
23.10 mantic 20240508 Ubuntu 23.10
24.04 noble,lts 20240423 Ubuntu 24.04 LTS
Blueprint Aliases Version Description
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker 0.4 A Docker environment with Portainer and related tools
jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube latest minikube is local Kubernetes
ros-noetic 0.1 A development and testing environment for ROS Noetic.
ros2-humble 0.1 A development and testing environment for ROS 2 Humble.
➜ k3s git:(main) multipass launch -c 1 -m 1G -d 4G -n k3s-master lts
Launched: k3s-master
➜ k3s git:(main) multipass info k3s-master
Name: k3s-master
State: Running
Snapshots: 0
IPv4: 192.168.64.4
Release: Ubuntu 24.04 LTS
Image hash: c841bac00925 (Ubuntu 24.04 LTS)
CPU(s): 1
Load: 0.06 0.07 0.02
Disk usage: 1.5GiB out of 3.8GiB
Memory usage: 218.4MiB out of 953.1MiB
Mounts: --
➜ k3s git:(main) for f in 1 2; do
multipass launch -c 1 -m 1G -d 4G -n k3s-worker-$f lts
done
Launched: k3s-worker-1
Launched: k3s-worker-2
➜ k3s git:(main) multipass list
Name State IPv4 Image
k3s-master Running 192.168.64.4 Ubuntu 24.04 LTS
k3s-worker-1 Running 192.168.64.5 Ubuntu 24.04 LTS
k3s-worker-2 Running 192.168.64.6 Ubuntu 24.04 LTS
➜ k3s git:(main) multipass exec k3s-master -- bash -c "curl -sfL
https://get.k3s.io
| sh -"
[INFO] Finding release for channel stable
[INFO] Using v1.29.4+k3s1 as release
[INFO] Downloading hash [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt)
[INFO] Downloading binary [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64)
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
➜ k3s git:(main) TOKEN=$(multipass exec k3s-master sudo cat /var/lib/rancher/k3s/server/node-token)
➜ k3s git:(main) IP=$(multipass info k3s-master | grep IPv4 | awk '{print $2}')
➜ k3s git:(main) for f in 1 2; do
multipass exec k3s-worker-$f -- bash -c "curl -sfL
https://get.k3s.io
| K3S_URL=\"https://$IP:6443\" K3S_TOKEN=\"$TOKEN\" sh -"
done
[INFO] Finding release for channel stable
[INFO] Using v1.29.4+k3s1 as release
[INFO] Downloading hash [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt)
[INFO] Downloading binary [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64)
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s-agent.service → /etc/systemd/system/k3s-agent.service.
[INFO] systemd: Starting k3s-agent
[INFO] Finding release for channel stable
[INFO] Using v1.29.4+k3s1 as release
[INFO] Downloading hash [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/sha256sum-arm64.txt)
[INFO] Downloading binary [https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64](https://github.com/k3s-io/k3s/releases/download/v1.29.4+k3s1/k3s-arm64)
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s-agent.service → /etc/systemd/system/k3s-agent.service.
[INFO] systemd: Starting k3s-agent
➜ k3s git:(main) multipass exec k3s-master -- bash
ubuntu@k3s-master:~$ `sudo kubectl get nodes`
NAME STATUS ROLES AGE VERSION
k3s-master Ready control-plane,master 5m53s v1.29.4+k3s1
k3s-worker-1 Ready <none> 2m30s v1.29.4+k3s1
k3s-worker-2 Ready <none> 2m16s v1.29.4+k3s1
CLEANUP
multipass list
multipass stop k3s-master k3s-worker-1 k3s-worker-2
multipass delete k3s-master k3s-worker-1 k3s-worker-2
multipass purge
multipass list
2) k3s getting started (kubectl)
===
brew install kubectl
===
inspiration: https://www.baeldung.com/ops/k3s-getting-started
➜ k3s git:(main) mkdir -p ~/.kube
➜ k3s git:(main) multipass exec k3s-master -- bash -c "sudo k3s kubectl config view --raw" | sed "s/127.0.0.1:6443/$IP:6443/" > ~/.kube/config
➜ k3s git:(main) ls -l ~/.kube/config
-rw-r–r– 1 tjen staff 2961 May 8 15:04 config
➜ k3s git:(main) chmod 600 ~/.kube/config
➜ k3s git:(main) ls -l ~/.kube/config
-rw------- 1 tjen staff 2961 May 8 15:04 config
➜ k3s git:(main) kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3s-worker-1 Ready <none> 24m v1.29.4+k3s1
k3s-worker-2 Ready <none> 23m v1.29.4+k3s1
k3s-master Ready control-plane,master 27m v1.29.4+k3s1
➜ k3s git:(main) kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6799fbcd5-rpw2m 1/1 Running 0 27m
kube-system local-path-provisioner-6c86858495-tj2sw 1/1 Running 0 27m
kube-system helm-install-traefik-crd-54r2h 0/1 Completed 0 27m
kube-system svclb-traefik-43a23560-226ds 2/2 Running 0 27m
kube-system helm-install-traefik-jzb5h 0/1 Completed 1 27m
kube-system traefik-7d5f6474df-29hdz 1/1 Running 0 27m
kube-system metrics-server-54fd9b65b-m5txb 1/1 Running 0 27m
kube-system svclb-traefik-43a23560-cc9hx 2/2 Running 0 24m
kube-system svclb-traefik-43a23560-xtbcl 2/2 Running 0 24m
➜ k3s git:(main) kubectl create deployment nginx --image=nginx --port=80 --replicas=3
deployment.apps/nginx created
➜ k3s git:(main) kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-7c5ddbdf54-82d48 0/1 ContainerCreating 0 6s
nginx-7c5ddbdf54-pqnwm 0/1 ContainerCreating 0 6s
nginx-7c5ddbdf54-vmvd5 0/1 ContainerCreating 0 6s
➜ k3s git:(main) kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-7c5ddbdf54-82d48 1/1 Running 0 50s
nginx-7c5ddbdf54-vmvd5 1/1 Running 0 50s
nginx-7c5ddbdf54-pqnwm 1/1 Running 0 50s
➜ k3s git:(main) kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 33m
➜ k3s git:(main) kubectl create service clusterip nginx --tcp=80:80
service/nginx created
➜ k3s git:(main) kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 33m
nginx ClusterIP 10.43.27.202 <none> 80/TCP 3s
➜ k3s git:(main) kubectl describe service nginx
Name: nginx
Namespace: default
Labels: app=nginx
Annotations: <none>
Selector: app=nginx
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.27.202
IPs: 10.43.27.202
Port: 80-80 80/TCP
TargetPort: 80/TCP
Endpoints: 10.42.0.9:80,10.42.1.3:80,10.42.2.3:80
Session Affinity: None
Events: <none>
➜ k3s git:(main) kubectl describe ingress nginx
Error from server (NotFound): ingresses.networking.k8s.io "nginx" not found
➜ k3s git:(main) vi nginx-ingress.yaml
➜ k3s git:(main) cat nginx-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
annotations:
ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
➜ k3s git:(main) kubectl apply -f nginx-ingress.yaml
ingress.networking.k8s.io/nginx created
➜ k3s git:(main) kubectl describe ingress nginx
Name: nginx
Labels: <none>
Namespace: default
Address: 192.168.64.4,192.168.64.5,192.168.64.6
Ingress Class: traefik
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
*
/ nginx:80 (10.42.0.9:80,10.42.1.3:80,10.42.2.3:80)
Annotations: ingress.kubernetes.io/ssl-redirect: false
Events: <none>
**CLEANUP**
**reverse**: `kubectl apply -f nginx-ingress.yaml`
➜ k3s git:(main) kubectl delete -f nginx-ingress.yaml
ingress.networking.k8s.io "nginx" deleted
➜ k3s git:(main) kubectl describe ingress nginx
Error from server (NotFound): ingresses.networking.k8s.io "nginx" not found
reverse: kubectl create service clusterip nginx --tcp=80:80
➜ k3s git:(main) kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 64m
nginx ClusterIP 10.43.27.202 <none> 80/TCP 30m
➜ k3s git:(main) kubectl delete service nginx
service "nginx" deleted
➜ k3s git:(main) kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 65m
reverse: kubectl create deployment nginx --image=nginx --port=80 --replicas=3
➜ helloworld-go git:(main) kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-7c5ddbdf54-82d48 1/1 Running 0 5h50m
nginx-7c5ddbdf54-vmvd5 1/1 Running 0 5h50m
nginx-7c5ddbdf54-pqnwm 1/1 Running 0 5h50m
➜ helloworld-go git:(main) kubectl delete deployment nginx
deployment.apps "nginx" deleted
➜ helloworld-go git:(main) kubectl get pods
NAME READY STATUS RESTARTS AGE
3) helm
===
brew install helm
➜ k3s git:(main) helm version
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable" via:
WARNING: helm repo add "stable" "https://charts.helm.sh/stable" --force-update
version.BuildInfo{Version:"v3.14.4", GitCommit:"81c902a123462fd4052bc5e9aa9c513c4c8fc142", GitTreeState:"clean", GoVersion:"go1.22.2"}
➜ k3s git:(main) helm repo add "stable" "https://charts.helm.sh/stable" --force-update
WARNING: "kubernetes-charts.storage.googleapis.com" is deprecated for "stable" and will be deleted Nov. 13, 2020.
WARNING: You should switch to "https://charts.helm.sh/stable" via:
WARNING: helm repo add "stable" "https://charts.helm.sh/stable" --force-update
"stable" has been added to your repositories
➜ k3s git:(main) helm version
version.BuildInfo{Version:"v3.14.4", GitCommit:"81c902a123462fd4052bc5e9aa9c513c4c8fc142", GitTreeState:"clean", GoVersion:"go1.22.2"}
inspiration: https://medium.com/@RedBaronDr1/helm-vs-kubectl-5aaf2dba7d71
➜ k3s git:(main) git clone
https://github.com/knative/docs
knative-docs
…
➜ k3s git:(main) cd knative-docs/code-samples/serving/hello-world/helloworld-go
➜ helloworld-go git:(main) ls
Dockerfile README.md go.mod helloworld.go service.yaml
➜ helloworld-go git:(main) docker run -it tjenwellens/helloworld-go:latest -p 8080:8080
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "-p": executable file not found in $PATH: unknown.
➜ helloworld-go git:(main) docker run -it -p 8080:8080 tjenwellens/helloworld-go:latest
2024/05/08 19:58:40 helloworld: starting server...
2024/05/08 19:58:40 helloworld: listening on port 8080
2024/05/08 19:58:48 helloworld: received a request
2024/05/08 19:58:48 helloworld: received a request
^C%
➜ helloworld-go git:(main) helm create .
Creating .
➜ helloworld-go git:(main) ✗ vi Chart.yaml
➜ helloworld-go git:(main) ✗ cat Chart.yaml
apiVersion: v2
name: helloworld-go
description: A Helm chart for Kubernetes
# ...
type: application
# ...
version: 0.1.0
# ...
appVersion: "0.1.0"
➜ helloworld-go git:(main) ✗ vi templates/deployment.yaml
➜ helloworld-go git:(main) ✗ cat templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "..fullname" . }}
labels:
{{- include "..labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "..selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "..labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "..serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: **<u>docker.io/tjenwellens/helloworld-go</u>**
imagePullPolicy: **<u>IfNotPresent</u>**
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
**<u> targetPort: 8080</u>**
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- 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 }}
➜ helloworld-go git:(main) ✗ helm install helloworld-go .
W0508 21:06:25.393281 82314 warnings.go:70] unknown field "spec.template.spec.containers[0].ports[0].targetPort"
NAME: helloworld-go
LAST DEPLOYED: Wed May 8 21:06:25 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helloworld-go,app.kubernetes.io/instance=helloworld-go" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit [http://127.0.0.1:8080](http://127.0.0.1:8080) to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
➜ helloworld-go git:(main) ✗ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-go-7c9ff6775f-s2qdl 0/1 ImagePullBackOff 0 8m48s
**#// probably failed because images was never pushed, it cannot pull it from docker.io hub**
➜ helloworld-go git:(main) ✗ docker push tjenwellens/helloworld-go
Using default tag: latest
The push refers to repository [docker.io/tjenwellens/helloworld-go]
6d5df439fd1f: Preparing
75d06a094c93: Preparing
b09314aec293: Preparing
denied: requested access to the resource is denied
**#// password needs to be Personal Access Token from **[**https://hub.docker.com/settings/security**](https://hub.docker.com/settings/security)
➜ helloworld-go git:(main) ✗ docker login
Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to [https://hub.docker.com/](https://hub.docker.com/) to create one.
You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at [https://docs.docker.com/go/access-tokens/](https://docs.docker.com/go/access-tokens/)
Username: tjenwellens
Password:
WARNING! Your password will be stored unencrypted in /Users/tjen/.docker/config.json.
Configure a credential helper to remove this warning. See
[https://docs.docker.com/engine/reference/commandline/login/#credentials-store](https://docs.docker.com/engine/reference/commandline/login/#credentials-store)
Login Succeeded
➜ helloworld-go git:(main) ✗ docker push tjenwellens/helloworld-go
Using default tag: latest
The push refers to repository [docker.io/tjenwellens/helloworld-go]
6d5df439fd1f: Pushed
75d06a094c93: Pushed
b09314aec293: Mounted from library/alpine
latest: digest: sha256:21f452f905d1453d914641ad98fd23d36282ccab688a1ea123689584699051ce size: 949
➜ helloworld-go git:(main) ✗ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-go-7c9ff6775f-s2qdl 0/1 ImagePullBackOff 0 20m
**#// don't want to wait on the ImagePullBackOff to try again, so deleting and redoing**
➜ helloworld-go git:(main) ✗ helm uninstall helloworld-go
release "helloworld-go" uninstalled
➜ helloworld-go git:(main) ✗ kubectl get pods
No resources found in default namespace.
➜ helloworld-go git:(main) ✗ helm install helloworld-go .
W0508 21:27:25.580316 84203 warnings.go:70] unknown field "spec.template.spec.containers[0].ports[0].targetPort"
NAME: helloworld-go
LAST DEPLOYED: Wed May 8 21:27:25 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helloworld-go,app.kubernetes.io/instance=helloworld-go" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit [http://127.0.0.1:8080](http://127.0.0.1:8080) to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
➜ helloworld-go git:(main) ✗ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-go-7c9ff6775f-xchzd 0/1 Running 0 8s
**#// keeps failing and restarting...**
➜ helloworld-go git:(main) ✗ `kubectl get pods`
NAME READY STATUS RESTARTS AGE
helloworld-go-7c9ff6775f-xchzd 0/1 Running 3 (17s ago) 108s
➜ helloworld-go git:(main) ✗ kubectl logs helloworld-go-7c9ff6775f-xchzd --previous
2024/05/08 20:29:26 helloworld: starting server...
2024/05/08 20:29:26 helloworld: listening on port 8080
➜ helloworld-go git:(main) ✗ kubectl logs helloworld-go-7c9ff6775f-xchzd
2024/05/08 20:29:26 helloworld: starting server...
2024/05/08 20:29:26 helloworld: listening on port 8080
**#// pod logs look good**
**#// lets check if something else is the problem**
➜ helloworld-go git:(main) ✗ kubectl describe pod helloworld-go-7c9ff6775f-xchzd
Name: helloworld-go-7c9ff6775f-xchzd
Namespace: default
Priority: 0
Service Account: helloworld-go
Node: k3s-worker-1/192.168.64.5
Start Time: Wed, 08 May 2024 21:27:25 +0100
Labels: app.kubernetes.io/instance=helloworld-go
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=helloworld-go
app.kubernetes.io/version=0.1.0
helm.sh/chart=helloworld-go-0.1.0
pod-template-hash=7c9ff6775f
Annotations: <none>
Status: Running
IP: 10.42.1.4
IPs:
IP: 10.42.1.4
Controlled By: ReplicaSet/helloworld-go-7c9ff6775f
Containers:
helloworld-go:
Container ID: containerd://08c154fdee1dbbaed2ae8d6b63571cc9ee74e977e9016d166f333c4976bbac03
Image: docker.io/tjenwellens/helloworld-go
Image ID: docker.io/tjenwellens/helloworld-go@sha256:21f452f905d1453d914641ad98fd23d36282ccab688a1ea123689584699051ce
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Wed, 08 May 2024 21:31:16 +0100
Last State: Terminated
Reason: Error
Exit Code: 2
Started: Wed, 08 May 2024 21:30:45 +0100
Finished: Wed, 08 May 2024 21:31:16 +0100
Ready: False
Restart Count: 6
Liveness: http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
Readiness: http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-j8f5t (ro)
Conditions:
Type Status
PodReadyToStartContainers True
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-api-access-j8f5t:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m58s default-scheduler Successfully assigned default/helloworld-go-7c9ff6775f-xchzd to k3s-worker-1
Normal Pulling 3m58s kubelet Pulling image "docker.io/tjenwellens/helloworld-go"
Normal Pulled 3m55s kubelet Successfully pulled image "docker.io/tjenwellens/helloworld-go" in 3.005s (3.005s including waiting)
Normal Killing 3m28s kubelet Container helloworld-go failed liveness probe, will be restarted
Normal Pulled 3m28s kubelet Container image "docker.io/tjenwellens/helloworld-go" already present on machine
Normal Created 3m28s (x2 over 3m55s) kubelet Created container helloworld-go
Normal Started 3m28s (x2 over 3m55s) kubelet Started container helloworld-go
Warning Unhealthy 3m8s (x5 over 3m48s) kubelet Liveness probe failed: Get "http://10.42.1.4:80/": dial tcp 10.42.1.4:80: connect: connection refused
Warning Unhealthy 2m58s (x12 over 3m54s) kubelet Readiness probe failed: Get "http://10.42.1.4:80/": dial tcp 10.42.1.4:80: connect: connection refused
**#// looks like a liveness and readiness check on port 80**
**#// why port 80? something default in the helm chart maybe?**
➜ helloworld-go git:(main) ✗ cat templates/deployment.yaml
...
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }
...
➜ helloworld-go git:(main) ✗ cat values.yaml
...
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
...
**#// let's hardcode that in like previously**
➜ helloworld-go git:(main) ✗ vi templates/deployment.yaml
➜ helloworld-go git:(main) ✗ cat templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "..fullname" . }}
labels:
{{- include "..labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "..selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "..labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "..serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: docker.io/tjenwellens/helloworld-go
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
targetPort: 8080
livenessProbe:
**<u> httpGet:</u>**
**<u> path: /</u>**
**<u> port: 8080</u>**
readinessProbe:
**<u> httpGet:</u>**
**<u> path: /</u>**
**<u> port: 8080</u>**
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- 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 }}
➜ helloworld-go git:(main) ✗ helm uninstall helloworld-go
release "helloworld-go" uninstalled
➜ helloworld-go git:(main) ✗ helm install helloworld-go .
W0508 21:45:37.837400 85689 warnings.go:70] unknown field "spec.template.spec.containers[0].ports[0].targetPort"
NAME: helloworld-go
LAST DEPLOYED: Wed May 8 21:45:37 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helloworld-go,app.kubernetes.io/instance=helloworld-go" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit [http://127.0.0.1:8080](http://127.0.0.1:8080) to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
➜ helloworld-go git:(main) ✗ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-go-cbb5668d9-rtqcr 1/1 Running 0 4m26s
**#// yeey, no restarts**
**#// but this warning from the helm install is fishy:**
W0508 21:45:37.837400 85689 warnings.go:70] unknown field "spec.template.spec.containers[0].ports[0].targetPort"
**#// maybe that was using the wrong field, and defaulted everything to port 80... (src: **[**https://kubernetes.io/docs/tutorials/services/connect-applications-service/)**](https://kubernetes.io/docs/tutorials/services/connect-applications-service/))
➜ helloworld-go git:(main) vi templates/deployment.yaml
➜ helloworld-go git:(main) ✗ cat templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "..fullname" . }}
labels:
{{- include "..labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "..selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "..labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "..serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: **docker.io/tjenwellens/helloworld-go**
imagePullPolicy: **IfNotPresent**
ports:
- name: http
containerPort: **8080**
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- 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 }}
➜ helloworld-go git:(main) ✗ helm uninstall helloworld-go
release "helloworld-go" uninstalled
➜ helloworld-go git:(main) ✗ helm install helloworld-go .
NAME: helloworld-go
LAST DEPLOYED: Wed May 8 21:56:29 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helloworld-go,app.kubernetes.io/instance=helloworld-go" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit [http://127.0.0.1:8080](http://127.0.0.1:8080) to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
➜ helloworld-go git:(main) ✗ `kubectl get pods`
NAME READY STATUS RESTARTS AGE
helloworld-go-77f765d499-gzlh9 1/1 Running 0 15s
**#// let's continue with the tutorial**
➜ helloworld-go git:(main) ✗ `kubectl get pods`
NAME READY STATUS RESTARTS AGE
helloworld-go-77f765d499-gzlh9 1/1 Running 0 3m3s
➜ helloworld-go git:(main) ✗ kubectl port-forward helloworld-go-77f765d499-gzlh9
8080:8080
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
➜ k3s git:(main) ✗ echo $IP
192.168.64.4
#// port forward stuff does not seem to be working
➜ helloworld-go git:(main) ✗ helm get manifest helloworld-go
---
# Source: helloworld-go/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
automountServiceAccountToken: true
---
# Source: helloworld-go/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
---
# Source: helloworld-go/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
template:
metadata:
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
serviceAccountName: helloworld-go
securityContext:
{}
containers:
- name: helloworld-go
securityContext:
{}
image: docker.io/tjenwellens/helloworld-go
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{}
**#// Where is the ingress?: ServiceAccount, Service, Deployment **
**#// **[**https://dwdraju.medium.com/how-deployment-service-ingress-are-related-in-their-manifest-a2e553cf0ffb**](https://dwdraju.medium.com/how-deployment-service-ingress-are-related-in-their-manifest-a2e553cf0ffb)

➜ helloworld-go git:(main) ✗ cat templates/ingress.yaml
**{{- if .Values.ingress.enabled -}}**
{{- $fullName := include "..fullname" . -}}
{{- $svcPort := .Values.service.port -}}
➜ helloworld-go git:(main) ✗ `cat values.yaml`
...
ingress:
enabled: **false**
className: ""
...
➜ helloworld-go git:(main) ✗ `cat templates/ingress.yaml`
rules:
{{- range .Values.ingress.hosts }}
- **host: {{ .host | quote }}**
http:
➜ helloworld-go git:(main) ✗ `vi values.yaml`
...
ingress:
enabled: **true**
className: ""
...
➜ helloworld-go git:(main) ✗ `vi templates/ingress.yaml`
...
rules:
{{- range .Values.ingress.hosts }}
** - http:**
paths:
{{- range .paths }}
- path: {{ .path }}
...
**#// src **[**https://helm.sh/docs/chart_template_guide/control_structures/**](https://helm.sh/docs/chart_template_guide/control_structures/)
➜ helloworld-go git:(main) helm install --dry-run --debug helloworld-go .
install.go:218: [debug] Original chart version: ""
install.go:235: [debug] CHART PATH: /Users/tjen/dev/tjen/plex-server/k3s/knative-docs/code-samples/serving/hello-world/helloworld-go
NAME: helloworld-go
LAST DEPLOYED: Thu May 9 08:41:15 2024
NAMESPACE: default
STATUS: pending-install
REVISION: 1
USER-SUPPLIED VALUES:
{}
COMPUTED VALUES:
affinity: {}
autoscaling:
enabled: false
maxReplicas: 100
minReplicas: 1
targetCPUUtilizationPercentage: 80
fullnameOverride: ""
image:
pullPolicy: IfNotPresent
repository: nginx
tag: ""
imagePullSecrets: []
ingress:
annotations: {}
className: ""
enabled: true
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
livenessProbe:
httpGet:
path: /
port: http
nameOverride: ""
nodeSelector: {}
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
readinessProbe:
httpGet:
path: /
port: http
replicaCount: 1
resources: {}
securityContext: {}
service:
port: 8080
type: ClusterIP
serviceAccount:
annotations: {}
automount: true
create: true
name: ""
tolerations: []
volumeMounts: []
volumes: []
HOOKS:
---
# Source: helloworld-go/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "helloworld-go-test-connection"
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['helloworld-go:8080']
restartPolicy: Never
MANIFEST:
---
# Source: helloworld-go/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
automountServiceAccountToken: true
---
# Source: helloworld-go/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
---
# Source: helloworld-go/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
template:
metadata:
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
serviceAccountName: helloworld-go
securityContext:
{}
containers:
- name: helloworld-go
securityContext:
{}
image: docker.io/tjenwellens/helloworld-go
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{}
---
# Source: helloworld-go/templates/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
rules:
- http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: helloworld-go
port:
number: 8080
NOTES:
1. Get the application URL by running these commands:
[http://chart-example.local/](http://chart-example.local/)
➜ helloworld-go git:(main) `helm uninstall helloworld-go`
release "helloworld-go" uninstalled
➜ helloworld-go git:(main) `helm install helloworld-go .`
NAME: helloworld-go
LAST DEPLOYED: Thu May 9 08:37:25 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
[http://chart-example.local/](http://chart-example.local/)
➜ k3s git:(main) ✗ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
helloworld-go traefik * 192.168.64.4,192.168.64.5,192.168.64.6 80 109s
➜ helloworld-go git:(main) curl 192.168.64.6
Hello World!
#// minimal changes
➜ helloworld-go git:(main) ✗ rm -r templates/ values.yaml .helmignore Chart.yaml
➜ helloworld-go git:(main) ✗ helm create .
Creating .
#// do the minimal changes
➜ helloworld-go git:(main) ✗ git diff HEAD^
diff --git a/code-samples/serving/hello-world/helloworld-go/Chart.yaml b/code-samples/serving/hello-world/helloworld-go/Chart.yaml
index 21954530..0f944a12 100644
--- a/code-samples/serving/hello-world/helloworld-go/Chart.yaml
+++ b/code-samples/serving/hello-world/helloworld-go/Chart.yaml
@@ -1,5 +1,5 @@
apiVersion: v2
-name: .
+name: helloworld-go
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
@@ -21,4 +21,4 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
-appVersion: "1.16.0"
+appVersion: "0.1.0"
diff --git a/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml b/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
index 2af0f616..b0be6011 100644
--- a/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
+++ b/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
@@ -38,8 +38,7 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- - host: {{ .host | quote }}
- http:
+ - http:
paths:
{{- range .paths }}
- path: {{ .path }}
diff --git a/code-samples/serving/hello-world/helloworld-go/values.yaml b/code-samples/serving/hello-world/helloworld-go/values.yaml
index 8ff356a6..00bb3d70 100644
--- a/code-samples/serving/hello-world/helloworld-go/values.yaml
+++ b/code-samples/serving/hello-world/helloworld-go/values.yaml
@@ -5,10 +5,10 @@
replicaCount: 1
image:
- repository: nginx
+ repository: docker.io/tjenwellens/helloworld-go
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
- tag: ""
+ tag: "latest"
imagePullSecrets: []
nameOverride: ""
@@ -41,10 +41,10 @@ securityContext: {}
service:
type: ClusterIP
- port: 80
+ port: 8080
ingress:
- enabled: false
+ enabled: true
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
➜ helloworld-go git:(main) ✗ helm install --dry-run helloworld-go .
NAME: helloworld-go
LAST DEPLOYED: Thu May 9 09:08:06 2024
NAMESPACE: default
STATUS: pending-install
REVISION: 1
HOOKS:
---
# Source: helloworld-go/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "helloworld-go-test-connection"
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['helloworld-go:8080']
restartPolicy: Never
MANIFEST:
---
# Source: helloworld-go/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
automountServiceAccountToken: true
---
# Source: helloworld-go/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
---
# Source: helloworld-go/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
template:
metadata:
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
serviceAccountName: helloworld-go
securityContext:
{}
containers:
- name: helloworld-go
securityContext:
{}
image: "docker.io/tjenwellens/helloworld-go:latest"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{}
---
# Source: helloworld-go/templates/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: helloworld-go
labels:
helm.sh/chart: helloworld-go-0.1.0
app.kubernetes.io/name: helloworld-go
app.kubernetes.io/instance: helloworld-go
app.kubernetes.io/version: "0.1.0"
app.kubernetes.io/managed-by: Helm
spec:
rules:
- http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: helloworld-go
port:
number: 8080
NOTES:
1. Get the application URL by running these commands:
[http://chart-example.local/](http://chart-example.local/)
**#// still bothers me that we need to change the default helm ingress template**
**#// what if we fake the domain in the curl request? (prefer not changing my /etc/hosts)**
**#// inspiration **[**https://www.hoelzel.it/hints/2022/01/25/fake-hostheader-with-curl.html**](https://www.hoelzel.it/hints/2022/01/25/fake-hostheader-with-curl.html)**, **[**https://stackoverflow.com/questions/2733873/how-can-i-revert-a-single-file-to-a-previous-version**](https://stackoverflow.com/questions/2733873/how-can-i-revert-a-single-file-to-a-previous-version)
➜ helloworld-go git:(main) ✗ git reset HEAD^ -- templates/ingress.yaml
Unstaged changes after reset:
M code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
➜ helloworld-go git:(main) ✗ git restore templates/ingress.yaml
➜ helloworld-go git:(main) ✗ git diff --staged
diff --git a/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml b/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
index b0be6011..2af0f616 100644
--- a/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
+++ b/code-samples/serving/hello-world/helloworld-go/templates/ingress.yaml
@@ -38,7 +38,8 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- - http:
+ - host: {{ .host | quote }}
+ http:
paths:
{{- range .paths }}
- path: {{ .path }}
➜ helloworld-go git:(main) ✗ `helm uninstall helloworld-go`
release "helloworld-go" uninstalled
➜ helloworld-go git:(main) ✗ `helm install helloworld-go .`
NAME: helloworld-go
LAST DEPLOYED: Thu May 9 09:10:33 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
[http://chart-example.local/](http://chart-example.local/)
➜ helloworld-go git:(main) ✗ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
helloworld-go traefik chart-example.local 192.168.64.4,192.168.64.5,192.168.64.6 80 6s
➜ helloworld-go git:(main) ✗ curl 192.168.64.4
404 page not found
➜ helloworld-go git:(main) ✗ curl --resolve chart-example.local:80:192.168.64.4
http://chart-example.local/
Hello World!
#// yeey, no more changed needed in the templates!
