Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions chapter3/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,38 @@ If Helm has already been initialized on the cluster, then you may have to upgrad

helm reset --force

== 3.9 Deploy Application to Kubernetes using Helm version 3 Charts

**Code**

. Install the Helm CLI:

brew install kubernetes-helm
+
If Helm CLI is already installed then use `brew upgrade kubernetes-helm`.
+
. Check Helm version:

helm version

. Change to `manifests/charts` directory
. Install the Helm chart:

helm install myapp ./myapp

. Check that the resources are running:

kubectl get svc,deployment,pods

. Access the application:

curl http://$(kubectl get svc/greeting \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):8080/hello

. Delete the Helm chart:

helm uninstall myapp

== 3.10 Debug Kubernetes Deployment using IntelliJ

**Code**
Expand Down Expand Up @@ -241,3 +273,51 @@ image::images/docker-debug3.png[]

helm delete --purge myapp

== 3.10 Debug Kubernetes Deployment using IntelliJ with Helm version 3

**Code**

You can debug a Kubernetes Pod if they're running on your machine.

This was tested using Docker Desktop.

. Install the Helm chart:

helm install myapp myapp

. Show service:
+
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
greeting LoadBalancer 10.99.253.180 localhost 8080:30194/TCP,5005:31755/TCP 2m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 123d
+
Highlight the debug port is also forwarded.
+
. In IntelliJ, `Run`, `Debug`, `Remote`:
+
image::images/docker-debug1.png[]
+
. Click on `Debug`, setup a breakpoint in the class:
+
image::images/docker-debug2.png[]
+
Wait for about 10 seconds.
+
. Access the application:

curl http://$(kubectl get svc/greeting \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):8080/hello

. Show the breakpoint hit in IntelliJ:
+
image::images/docker-debug3.png[]
+
. Click on green button to continue execution
. Invoke the application:

curl http://locahost:8080/hello

. Delete the Helm chart:

helm uninstall myapp
44 changes: 44 additions & 0 deletions chapter4/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,47 @@ It shows the port `8080` and `5005` are published and an Elastic Load Balancer i

helm delete --purge myapp

== 4.3 Migrate Application to Kubernetes Cluster on AWS with Helm version 3

**Code**

. Explicitly set the context:

kubectl config use-context [email protected]

. Check the list of pods:

kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
aws-node-6h4r9 1/1 Running 1 16m
aws-node-7rwkw 1/1 Running 1 16m
aws-node-k9g6s 1/1 Running 0 16m
aws-node-t6k6v 1/1 Running 1 16m
kube-dns-64b69465b4-vpxjq 3/3 Running 0 23m
kube-proxy-bnkj6 1/1 Running 0 16m
kube-proxy-bqths 1/1 Running 0 16m
kube-proxy-m7ctf 1/1 Running 0 16m
kube-proxy-tszj5 1/1 Running 0 16m
tiller-deploy-895d57dd9-zt2s2 1/1 Running 0 7s

. Redeploy the application:

helm install myapp manifests/charts/myapp

. Get the service:
+
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
greeting LoadBalancer 10.100.110.146 a798a47cd104211e986290adde103247-521253658.us-west-2.elb.amazonaws.com 8080:31627/TCP,5005:30216/TCP 2m
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 18h
+
It shows the port `8080` and `5005` are published and an Elastic Load Balancer is provisioned. It takes about three minutes for the load balancer to be ready.
+
. Access the application:

curl http://$(kubectl get svc/greeting \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):8080/hello

. Delete the application:

helm uninstall myapp
14 changes: 14 additions & 0 deletions chapter5/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ More details at https://aws.amazon.com/blogs/opensource/getting-started-istio-ek
--namespace istio-system \
install/kubernetes/helm/istio

. With Helm v3:

helm install \
istio \
install/kubernetes/helm/istio \
--wait \
--namespace istio-system

. Verify the list of pods:

kubectl get pods -n istio-system
Expand Down Expand Up @@ -63,6 +71,10 @@ More details at https://aws.amazon.com/blogs/opensource/getting-started-istio-ek

helm delete myapp --purge
helm install --name myapp myapp-hello-howdy

#helm v3
helm uninstall myapp
helm install myapp myapp-hello-howdy
+
Note, there is no `type: LoadBalancer` in this case. The service will be exposed using Istio Ingress gateway so that Istio can do the traffic split.
+
Expand Down Expand Up @@ -191,5 +203,7 @@ image::images/kiali-apps.png[]
. Remove Istio

helm delete istio --purge
#helm v3
helm uninstall istio
kubectl delete -f install/kubernetes/helm/istio/templates/crds.yaml -n istio-system

7 changes: 7 additions & 0 deletions chapter6/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ https://github.com/GoogleContainerTools/skaffold[Skaffold] is a command line uti

helm delete myapp --purge

#helm v3
helm uninstall myapp

. Download Skaffold:

brew install skaffold
Expand All @@ -52,6 +55,10 @@ https://github.com/GoogleContainerTools/skaffold[Skaffold] is a command line uti

. Refresh the page in browser to see the output.

. Remove the Skaffold resources from the application directory:

skaffold delete

Same Java application, now continuously built through Skaffold and deployed to a local Kubernetes cluster. This can also be integrated with Jib. This can also be deployed to a remote Kubernetes cluster.

=== 6.2 AWS CodePipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: greeting-hello
Expand All @@ -7,6 +7,9 @@ metadata:
{{- template "labels" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: greeting
template:
metadata:
labels:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: greeting-howdy
Expand All @@ -7,6 +7,9 @@ metadata:
{{- template "labels" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: greeting
template:
metadata:
labels:
Expand Down
13 changes: 8 additions & 5 deletions manifests/charts/myapp/templates/greeting-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: greeting
name: {{ .Chart.Name }}
labels:
name: greeting
name: {{ .Chart.Name }}
{{- template "labels" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Chart.Name }}
template:
metadata:
labels:
app: greeting
app: {{ .Chart.Name }}
spec:
containers:
- name: greeting
- name: {{ .Chart.Name }}
image: {{ .Values.greeting.image }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down
6 changes: 3 additions & 3 deletions manifests/charts/myapp/templates/greeting-service.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: greeting
name: {{ .Chart.Name }}
labels:
name: greeting
name: {{ .Chart.Name }}
{{- template "labels" . }}
spec:
selector:
app: greeting
app: {{ .Chart.Name }}
ports:
- name: http
protocol: TCP
Expand Down