From 8d64c2970745c8ded896bc40d6dbf612ec3c2465 Mon Sep 17 00:00:00 2001 From: ehvs Date: Sat, 25 May 2024 22:07:56 +0200 Subject: [PATCH] fixed slug --- docs/blog/posts/helmchart-from-scratch.md | 66 +++++++++++------------ 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/docs/blog/posts/helmchart-from-scratch.md b/docs/blog/posts/helmchart-from-scratch.md index f42bebc..a7a2215 100644 --- a/docs/blog/posts/helmchart-from-scratch.md +++ b/docs/blog/posts/helmchart-from-scratch.md @@ -9,12 +9,12 @@ date: updated: 2024-05-25 categories: - Labs -slug: images +slug: helmchart-from-scratch tags: - crc, helmchart, openshift --- On this exercise, we will deploy an application from scratch using Helm Chart. - + ## Environment & Pre-requisites @@ -30,10 +30,10 @@ version.BuildInfo{Version:"v3.13.2+35.el9", GitCommit:"fa6e939d7984e1be0d6fbc2dc ``` ### Setup registry authentication -1. If using OpenShift, it is necessary to update the pullsecret in the cluster with the necessary registry authentication. +If using OpenShift, it is necessary to update the pullsecret in the cluster with the necessary registry authentication. To verify: ``` -oc get secret/pull-secret -n openshift-config --template='{{index .data ".dockerconfigjson" | base64decode}}' +❯ oc get secret/pull-secret -n openshift-config --template='{{index .data ".dockerconfigjson" | base64decode}}' ``` ## Starting with helm @@ -74,7 +74,7 @@ serviceAccount: 3. Deploy the application with `helm install`. ``` -helm install mynginx-chart mynginx/ --values mynginx/values.yaml +❯ helm install mynginx-chart mynginx/ --values mynginx/values.yaml NAME: mynginx-chart LAST DEPLOYED: Sat May 25 12:56:37 2024 NAMESPACE: default @@ -88,45 +88,43 @@ NOTES: kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT ``` -3.2 Verify that the pod is running -``` -oc get pods -NAME READY STATUS RESTARTS AGE -mynginx-chart-mynginx-664dfbb4b4-r7xqq 1/1 Running 0 13s -``` - -4. Expose the application service, and `curl` the route to verify if is up and running. -``` -❯ oc expose svc mynginx-chart-mynginx -route.route.openshift.io/mynginx-chart-mynginx exposed -❯ oc get route -NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD -mynginx-chart-mynginx mynginx-chart-mynginx-default.apps-crc.testing mynginx-chart-mynginx http None +4. Verify that the pod is running + ``` + ❯ oc get pods + NAME READY STATUS RESTARTS AGE + mynginx-chart-mynginx-664dfbb4b4-r7xqq 1/1 Running 0 13s + ``` +5. Expose the application service, and `curl` the route to verify if is up and running. + ``` + ❯ oc expose svc mynginx-chart-mynginx + route.route.openshift.io/mynginx-chart-mynginx exposed + ❯ oc get route + NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD + mynginx-chart-mynginx mynginx-chart-mynginx-default.apps-crc.testing mynginx-chart-mynginx http None -❯ curl -s -o /dev/null -w "remote_ip: %{remote_ip}\nremote_port: %{remote_port}\nresponse_code: %{response_code}\n" http://$ROUTE_NAME -remote_ip: 192.168.130.11 -remote_port: 80 -response_code: 200 -``` + ❯ curl -s -o /dev/null -w "remote_ip: %{remote_ip}\nremote_port: %{remote_port}\nresponse_code: %{response_code}\n" http://$ROUTE_NAME + remote_ip: 192.168.130.11 + remote_port: 80 + response_code: 200 + ``` ## Updating the deployment To update a current deployment from helmchart it is used `helm upgrade`, using that command there are some different ways ([documented here](#)), for this example we will modify the `service.type` to use `NodePort` by modifying the `values.yaml` 1. After modified, list the current releases (**must be ran inside the project context**) - > NOTE: A Release is an instance of a chart running in a Kubernetes cluster -``` -helm list -NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION -mynginx-chart default 1 2024-05-25 12:56:37.733458796 +0200 CEST deployed mynginx-0.1.0 1.16.0 -``` + ``` + ❯ helm list + NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION + mynginx-chart default 1 2024-05-25 12:56:37.733458796 +0200 CEST deployed mynginx-0.1.0 1.16.0 + ``` 2. Apply the modification. ``` -helm upgrade -f mynginx/values.yaml mynginx-chart mynginx/ +❯ helm upgrade -f mynginx/values.yaml mynginx-chart mynginx/ Release "mynginx-chart" has been upgraded. Happy Helming! NAME: mynginx-chart LAST DEPLOYED: Sat May 25 13:57:55 2024 @@ -142,11 +140,11 @@ NOTES: 3. Inspect the release list and history of each release. ``` -helm list +❯ helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION mynginx-chart default 2 2024-05-25 13:57:55.817936502 +0200 CEST deployed mynginx-0.1.0 1.16.0 -helm history mynginx-chart +❯ helm history mynginx-chart REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 1 Sat May 25 12:56:37 2024 superseded mynginx-0.1.0 1.16.0 Install complete 2 Sat May 25 13:57:55 2024 deployed mynginx-0.1.0 1.16.0 Upgrade complete @@ -154,7 +152,7 @@ REVISION UPDATED STATUS CHART APP VERSION DESCRIP 4. Validate that the pod is running, and because we are using nodePort using *CRC/OpenShift local*, due to limitations, we can only access via `port-forward`. Open a new terminal, or access via browser `127.0.0.1:32362`. ``` -oc port-forward svc/mynginx-chart-mynginx 32362:80 +❯ oc port-forward svc/mynginx-chart-mynginx 32362:80 Forwarding from 127.0.0.1:32362 -> 80 Forwarding from [::1]:32362 -> 80 Handling connection for 32362