Skip to content

Commit

Permalink
fixed slug
Browse files Browse the repository at this point in the history
  • Loading branch information
ehvs committed May 25, 2024
1 parent b2b98e9 commit 8d64c29
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions docs/blog/posts/helmchart-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- more -->

## Environment & Pre-requisites

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -142,19 +140,19 @@ 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
```

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
Expand Down

0 comments on commit 8d64c29

Please sign in to comment.