Room9

CKAD - Application Deployment (Helm) 본문

Kubernetes

CKAD - Application Deployment (Helm)

Room9_ 2022. 1. 26. 10:38

Helm

Kubernetes 상의 패키지 관리 툴이다. 쉽게 말해 윈도우에서 어떤 프로그램을 설치할 때 하나하나 설정하는 게 아니라 유저가 필요한 값만 변경하여 설치하는 설치 마법사와 비슷하다고 생각할 수 있다. 헬름은 Kubernetes 상의 이러한 구성을 미리 패키지 해두고 사용자는 해당 파일의 설정값만 바꿔서 사용할 수 있게 해주는 패키지 관리 툴이다. 

Helm을 사용하기 위해 알야아 할 최소한의 명령어 및 Helm 설치 과정에 대해 포스팅해보겠습니다.


KodeKloud - helm install

Q1.Identify the name of the Operating system installed.

root@controlplane:~# cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Q2. Install the helm package.

If unsure how to install the helm tool, feel free to refer to the documentation. The Documentation tab is available at the top right panel

https://helm.sh/docs/intro/install/#from-apt-debianubuntu

 

Installing Helm

Learn how to install and get running with Helm.

helm.sh

root@controlplane:~# curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1700  100  1700    0     0  15887      0 --:--:-- --:--:-- --:--:-- 15887
OK
root@controlplane:~# sudo apt-get install apt-transport-https --yes
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (1.6.14).
0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.
root@controlplane:~# echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
deb https://baltocdn.com/helm/stable/debian/ all main
root@controlplane:~# sudo apt-get update
Hit:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease                                                     
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                                              
Get:3 https://baltocdn.com/helm/stable/debian all InRelease [7652 B]                                                                                           
Hit:4 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                               
Hit:5 http://archive.ubuntu.com/ubuntu bionic InRelease                                              
Hit:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:8 https://baltocdn.com/helm/stable/debian all/main amd64 Packages [2739 B]
Fetched 10.4 kB in 1s (8314 B/s)                            
Reading package lists... Done
root@controlplane:~# sudo apt-get install helm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  helm
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
Need to get 13.6 MB of archives.
After this operation, 45.1 MB of additional disk space will be used.
Get:1 https://baltocdn.com/helm/stable/debian all/main amd64 helm amd64 3.8.0-1 [13.6 MB]
Fetched 13.6 MB in 0s (39.9 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package helm.
(Reading database ... 15210 files and directories currently installed.)
Preparing to unpack .../helm_3.8.0-1_amd64.deb ...
Unpacking helm (3.8.0-1) ...
Setting up helm (3.8.0-1) ...

Q3. Use the help page of helm command to identify the command used to retrieve helm client environment information.

root@controlplane:~# helm env
HELM_BIN="helm"
HELM_CACHE_HOME="/root/.cache/helm"
HELM_CONFIG_HOME="/root/.config/helm"
HELM_DATA_HOME="/root/.local/share/helm"
HELM_DEBUG="false"
HELM_KUBEAPISERVER=""
HELM_KUBEASGROUPS=""
HELM_KUBEASUSER=""
HELM_KUBECAFILE=""
HELM_KUBECONTEXT=""
HELM_KUBETOKEN=""
HELM_MAX_HISTORY="10"
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry/config.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"

Q4. Identify the version of helm installed on the cluster.

root@controlplane:~# helm version
version.BuildInfo{Version:"v3.8.0", GitCommit:"d14138609b01886f544b2025f5000351c9eb092e", GitTreeState:"clean", GoVersion:"go1.17.5"}

Q5. What is a command line flag used to enable verbose output?

root@controlplane:~# helm env
Flags:
      --debug                       enable verbose output

 > --debug


Q6. That’s all for now. That was a quick introduction to the helm command line utility. Feel free to explore the helm command line utility further. We will learn more about these commands throughout the remainder of this course.

 > OK


KodeKloud - helm uses

Q1. Which command is used to search for a wordpress helm chart package from the Artifact Hub?

root@controlplane:~# helm search hub wordpress
URL                                                     CHART VERSION   APP VERSION             DESCRIPTION                                       
https://artifacthub.io/packages/helm/kube-wordp...      0.1.0           1.1                     this is my wordpress package                      
https://artifacthub.io/packages/helm/bitnami/wo...      13.0.5          5.8.3                   WordPress is the world's most popular blogging ...
https://artifacthub.io/packages/helm/bitnami-ak...      13.0.4          5.8.3                   WordPress is the world's most popular blogging ...
https://artifacthub.io/packages/helm/riftbit/wo...      12.1.16         5.8.1                   Web publishing platform for building blogs and ...
https://artifacthub.io/packages/helm/sikalabs/w...      0.2.0                                   Simple Wordpress                                  
https://artifacthub.io/packages/helm/groundhog2...      0.4.10          5.8.3-apache            A Helm chart for Wordpress on Kubernetes          
https://artifacthub.io/packages/helm/homeenterp...      0.3.0           5.8.0-php8.0-apache     Blog server                                       
https://artifacthub.io/packages/helm/mcouliba/w...      0.1.0           1.16.0                  A Helm chart for Kubernetes                       
https://artifacthub.io/packages/helm/wordpress-...      1.0.0           1.1                     This is a package for configuring wordpress and...
https://artifacthub.io/packages/helm/securecode...      3.6.0           4.0                     Insecure & Outdated Wordpress Instance: Never e...
https://artifacthub.io/packages/helm/wordpressm...      1.0.0                                   This is the Helm Chart that creates the Wordpre...
https://artifacthub.io/packages/helm/bitpoke/wo...      0.12.1          v0.12.1                 Bitpoke WordPress Operator Helm Chart             
https://artifacthub.io/packages/helm/presslabs/...      0.11.0-alpha.3  0.11.0-alpha.3          Presslabs WordPress Operator Helm Chart           
https://artifacthub.io/packages/helm/presslabs/...      0.12.0          v0.12.0                 A Helm chart for deploying a WordPress site on ...
https://artifacthub.io/packages/helm/phntom/bin...      0.0.3           0.0.3                   www.binaryvision.co.il static wordpress           
https://artifacthub.io/packages/helm/gh-shessel...      1.0.35          5.8.2                   Web publishing platform for building blogs and ...
https://artifacthub.io/packages/helm/sikalabs/w...      0.1.0                                                                                     
https://artifacthub.io/packages/helm/bitpoke/bi...      1.8.0           1.8.0                   The Bitpoke App for WordPress provides a versat...
https://artifacthub.io/packages/helm/sonu-wordp...      1.0.0           2                       This is my custom chart to deploy wordpress and...
https://artifacthub.io/packages/helm/uvaise-wor...      0.2.0           1.1.0                   Wordpress for Kubernetes                          
https://artifacthub.io/packages/helm/wordpress/...      0.2.0           1.1.0                   Wordpress for Kubernetes                          
https://artifacthub.io/packages/helm/wordpress-...      1.0.0           2                       This is my custom chart to deploy wordpress and...
https://artifacthub.io/packages/helm/bitpoke/stack      0.12.0          v0.12.0                 Your Open-Source, Cloud-Native WordPress Infras...
https://artifacthub.io/packages/helm/securecode...      3.6.0           v3.8.20                 A Helm chart for the WordPress security scanner...
https://artifacthub.io/packages/helm/wordpresss...      1.1.0           5.8.2                   Web publishing platform for building blogs and ...
https://artifacthub.io/packages/helm/viveksahu2...      1.0.0           2                       This is my custom chart to deploy wordpress and...
https://artifacthub.io/packages/helm/presslabs/...      0.11.0-rc.2     v0.11.0-rc.2            Open-Source WordPress Infrastructure on Kubernetes
https://artifacthub.io/packages/helm/presslabs/...      0.12.0          v0.12.0                 Open-Source WordPress Infrastructure on Kubernetes
https://artifacthub.io/packages/helm/six/wordress       0.2.0           1.1.0                   Wordpress for Kubernetes                          
https://artifacthub.io/packages/helm/jinchi-cha...      0.2.0           1.1.0                   Wordpress for Kubernetes                          
https://artifacthub.io/packages/helm/wordpressm...      0.1.0           1.1                                                                       
https://artifacthub.io/packages/helm/presslabs/...      0.11.6          0.11.6                  Presslabs WordPress Operator Helm Chart

Q2. Add a bitnami helm chart repository in the controlplane node.

root@controlplane:~# helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
root@controlplane:~# helm repo list
NAME    URL                               
bitnami https://charts.bitnami.com/bitnami

Q3. Which command is used to search for the joomla package from the added repository?

root@controlplane:~# helm search repo joomla
NAME            CHART VERSION   APP VERSION     DESCRIPTION                                       
bitnami/joomla  12.0.3          4.0.6           Joomla! is an award winning open source CMS pla...

Q4. What is the app version of joomla in the bitnami helm repository?

 > 4.0.6


Q5. Which chart version can you see for the joomla package in the bitnami helm repo?

 > 12.0.3


Q6. How many helm repositories are added in the controlplane node?

root@controlplane:~# helm repo list
NAME            URL                                                 
bitnami         https://charts.bitnami.com/bitnami                  
puppet          https://puppetlabs.github.io/puppetserver-helm-chart
hashicorp       https://helm.releases.hashicorp.com

 > 3


Q7. Install drupal helm chart from the bitnami repository.

Release name should be bravo.
Chart name should be bitnami/drupal.

root@controlplane:~# helm repo list
NAME            URL                                                 
bitnami         https://charts.bitnami.com/bitnami                  
puppet          https://puppetlabs.github.io/puppetserver-helm-chart
hashicorp       https://helm.releases.hashicorp.com                 
root@controlplane:~# helm install bravo bitnami/drupal
NAME: bravo
LAST DEPLOYED: Wed Jan 26 01:44:40 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: drupal
CHART VERSION: 11.0.4
APP VERSION: 9.3.3** Please be patient while the chart is being deployed **

1. Get the Drupal URL:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w bravo-drupal'

  export SERVICE_IP=$(kubectl get svc --namespace default bravo-drupal --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
  echo "Drupal URL: http://$SERVICE_IP/"

2. Get your Drupal login credentials by running:

  echo Username: user
  echo Password: $(kubectl get secret --namespace default bravo-drupal -o jsonpath="{.data.drupal-password}" | base64 --decode)

root@controlplane:~# helm list
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
bravo   default         1               2022-01-26 01:44:40.357712948 +0000 UTC deployed        drupal-11.0.4   9.3.3

Q8. Which command is used to list packages installed using helm?

 > helm list


Q9. Uninstall the drupal helm package which we installed earlier.

root@controlplane:~# helm uninstall bravo 
release "bravo" uninstalled
root@controlplane:~# helm list
NAME    NAMESPACE       REVISION        UPDATED STATUS  CHART   APP VERSION

Q10. Download the bitnami apache package under the /root directory.

root@controlplane:~# helm pull bitnami/apache --untar
root@controlplane:~# ll
total 36
drwx------ 1 root root 4096 Jan 26 01:47 ./
drwxr-xr-x 1 root root 4096 Jan 26 01:30 ../
-rw-r--r-- 1 root root 3190 Jul 20  2021 .bashrc
drwx------ 3 root root 4096 Jan 26 01:40 .cache/
drwxr-xr-x 3 root root 4096 Jan 26 01:40 .config/
drwxr-xr-x 3 root root 4096 Jan 26 01:38 .kube/
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
drwx------ 2 root root 4096 Jan 26 01:38 .ssh/
drwxr-xr-x 6 root root 4096 Jan 26 01:47 apache/

Q11. Inspect the file values.yaml and make changes so that 2 replicas of webserver is running and the http is exposed on NodePort 30080.

values.yaml 수정

replicaCount: 2
service:
  type: NodePort
  nodePorts:
    http: 30080

Q12. Install the apache from the downloaded helm package.

Release name: mywebapp

root@controlplane:~/apache# helm install mywebapp .
NAME: mywebapp
LAST DEPLOYED: Wed Jan 26 01:52:06 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: apache
CHART VERSION: 9.0.1
APP VERSION: 2.4.52

** Please be patient while the chart is being deployed **

1. Get the Apache URL by running:

  export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services mywebapp-apache)
  export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT/


WARNING: You did not provide a custom web application. Apache will be deployed with a default page. Check the README section "Deploying your custom web application" in https://github.com/bitnami/charts/blob/master/bitnami/apache/README.md#deploying-your-custom-web-application.
root@controlplane:~/apache# helm list
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mywebapp        default         1               2022-01-26 01:52:06.288833182 +0000 UTC deployed        apache-9.0.1    2.4.52

Q13. You can access the Apache default page by clicking on mywebapp link from the top of the terminal.

 


 

Comments