Selasa, 17 September 2024

KUBERNETES-helm

 




https://medium.com/@harishpillai1994/helm-on-kubernetes-bf661695e117


https://snapcraft.io/install/helm/ubuntu

root@master-node:~# sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
snapd is already the newest version (2.63.1+24.04).
snapd set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.
root@master-node:~# sudo snap install helm --classic
helm 3.16.1 from Snapcrafters installed
root@master-node:~# helm version                     
version.BuildInfo{Version:"v3.16.1", GitCommit:"5a5449dc42be07001fd5771d56429132984ab3ab", GitTreeState:"clean", GoVersion:"go1.22.7"}
root@master-node:~# 

Helm di Kubernetes

Harishkumar Pillai
Waktu baca 6 menit

Nonanggota klik di sini .

Helm adalah pengelola paket untuk Kubernetes, platform orkestrasi kontainer. Helm membantu Anda mendefinisikan, memasang, dan meng-upgrade aplikasi Kubernetes yang kompleks. Paket Helm disebut "chart," yang berisi semua definisi sumber daya yang diperlukan untuk menjalankan aplikasi, alat, atau layanan di dalam kluster Kubernetes.

Bagaimana Helm Bekerja?

Helm menyederhanakan pengelolaan aplikasi Kubernetes dengan menyediakan tingkat abstraksi yang lebih tinggi melalui diagram. Berikut cara kerjanya:

1. Bagan Helm:

  • Bagan merupakan konsep inti dalam Helm. Bagan merupakan kumpulan file yang menggambarkan sekumpulan sumber daya Kubernetes yang terkait. Bagan berisi struktur direktori dengan format yang telah ditetapkan, termasuk templat, nilai konfigurasi, dependensi, dan metadata.
  • Bagan dapat dibagikan dan digunakan kembali, yang berarti Anda dapat menggunakan bagan yang dikelola komunitas untuk aplikasi populer atau membuat bagan kustom Anda sendiri.

2. Repositori Bagan:

  • Bagan dapat disimpan dalam repositori, seperti paket dalam pengelola paket Linux. Repositori publik (seperti Helm Hub resmi) menyediakan pustaka besar bagan siap pakai yang dapat langsung diinstal.
  • Anda juga dapat menyelenggarakan repositori Helm pribadi Anda sendiri…
===================================================================

Helm on Kubernetes

Non members click here.

Helm is a package manager for Kubernetes, the container orchestration platform. It helps you define, install, and upgrade complex Kubernetes applications. Helm packages are called “charts,” which contain all the resource definitions required to run an application, tool, or service inside a Kubernetes cluster.

How Does Helm Work?

Helm simplifies the management of Kubernetes applications by providing a higher level of abstraction through charts. Here’s how it works:

1. Helm Charts:

  • Charts are the core concept in Helm. A chart is a collection of files that describe a related set of Kubernetes resources. It contains a directory structure with a predefined format, including templates, configuration values, dependencies, and metadata.
  • Charts can be shared and reused, which means you can use community-maintained charts for popular applications or create your own custom charts.

2. Chart Repositories:

  • Charts can be stored in repositories, much like packages in a Linux package manager. Public repositories (like the official Helm Hub) provide a vast library of pre-built charts that can be installed directly.
  • You can also host your own private Helm repository to distribute internal charts within an organization.

3. Helm Release:

  • When you install a chart into a Kubernetes cluster, Helm creates a release. A release is a specific instance of a chart running in a Kubernetes cluster.
  • Multiple releases of the same chart can run in the same cluster, each with different configurations, making it easy to manage different environments (e.g., dev, staging, production).

4. Templates and Values:

  • Helm uses Go templates to define Kubernetes manifests (YAML files). These templates are parameterized with values that can be customized at installation time or through upgrades.
  • The values.yaml file in a chart contains default configurations, which can be overridden by providing custom values during installation or through a separate values file.

5. Installation and Upgrades:

  • Installation: To install a chart, you run the helm install command, specifying the chart and any configuration values. Helm then renders the templates into Kubernetes manifests and applies them to your cluster.
  • Upgrades: Helm makes it easy to upgrade applications. You can modify the values and run the helm upgrade command, and Helm will update the running release with the new configuration.

6. Rollback:

  • Helm tracks the history of releases, allowing you to rollback to a previous version if something goes wrong during an upgrade. This is done using the helm rollback command.

7. Dependencies:

  • Charts can depend on other charts, making it easy to manage complex applications with multiple components. Helm handles these dependencies automatically, installing or upgrading them as needed.

8. Lifecycle Management:

  • Helm provides commands for managing the entire lifecycle of Kubernetes applications, including listing installed releases (helm list), uninstalling releases (helm uninstall), and inspecting release status (helm status).

Example Workflow:

1. Create a Chart:

  • helm create mychart generates a new Helm chart with a basic directory structure.

2. Customize the Chart:

  • Modify the values.yaml file to set default values and edit the templates to define Kubernetes resources.

3. Install the Chart:

  • helm install myrelease mychart installs the chart into your Kubernetes cluster, creating a new release called myrelease.

4. Upgrade the Release:

  • helm upgrade myrelease mychart -f custom-values.yaml upgrades the release with new values from custom-values.yaml.

5. Rollback if Needed:

  • helm rollback myrelease 1 rolls back the release to the previous version.

Benefits of Using Helm:

  • Simplifies Kubernetes Deployments: Helm abstracts the complexity of managing Kubernetes resources by bundling them into reusable packages.
  • Version Control: Helm tracks versions of deployments, making upgrades and rollbacks straightforward.
  • Reuse and Share: Helm charts can be shared across teams or communities, promoting best practices and consistency.
  • Customizable: With the use of templates and values, Helm charts can be highly customized to fit different environments or use cases.
  • Dependency Management: Helm handles dependencies between different components of an application, ensuring everything is installed and configured in the correct order.

How to check the running operating system?

controlplane ~ ➜  cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
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"
UBUNTU_CODENAME=jammy

How to install helm?

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.

controlplane ~ ➜  curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

controlplane ~ ➜ chmod 700 get_helm.sh

controlplane ~ ➜ ./get_helm.sh
Helm v3.15.4 is available. Changing from version v3.15.3.
Downloading https://get.helm.sh/helm-v3.15.4-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm

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

controlplane ~ ➜  helm env
HELM_BIN="helm"
HELM_BURST_LIMIT="100"
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_KUBEINSECURE_SKIP_TLS_VERIFY="false"
HELM_KUBETLS_SERVER_NAME=""
HELM_KUBETOKEN=""
HELM_MAX_HISTORY="10"
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_QPS="0.00"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry/config.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"

Identify the version of helm installed on the cluster.

controlplane ~ ➜  helm version
version.BuildInfo{Version:"v3.15.4", GitCommit:"fa9efb07d9d8debbb4306d72af76a383895aa8c4", GitTreeState:"clean", GoVersion:"go1.22.6"}

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

controlplane ~ ➜  helm -h | grep -i verbose
--debug enable verbose output

Helm chart consists of

1. Templates

2. values.yaml

3. Chart.yaml

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

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/wordpress-... 1.0.2 1.0.0 A Helm chart for deploying Wordpress+Mariadb st...
https://artifacthub.io/packages/helm/bitnami/wo... 23.1.12 6.6.1 WordPress is the world's most popular blogging ...
...

How to add a bitnami helm chart repository in the controlplane node.

Name — bitnami

Chart repo name - https://charts.bitnami.com/bitnami

controlplane ~ ✖ helm repo add bitnami  https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

controlplane ~ ➜ helm search repo wordpress
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/wordpress 23.1.12 6.6.1 WordPress is the world's most popular blogging ...
bitnami/wordpress-intel 2.1.31 6.1.1 DEPRECATED WordPress for Intel is the most popu...

How many helm repositories are added in the controlplane node?

3

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

How to install a chart and name it?

Install drupal helm chart from the bitnami repository.

Release name should be bravo.

Chart name should be bitnami/drupal.

$ helm install [NAME] [CHART] [flags]

controlplane ~   helm install bravo bitnami/drupal
NAME: bravo
LAST DEPLOYED: Sat Sep 7 19:33:43 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: drupal
CHART VERSION: 20.0.4
APP VERSION: 11.0.2** Please be patient while the chart is being deployed **

The NAME which is used as bravo is a release name. We can create same helm installations with different release names.

How to list the installed packages

controlplane ~ ➜  helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
bravo default 1 2024-09-07 19:33:43.850316183 +0000 UTC deployed drupal-20.0.4 11.0.2

How to uninstall packages?

controlplane ~ ➜  helm uninstall bravo
release "bravo" uninstalled

How to download the bitnami apache package under the /root directory.

First search the package

controlplane ~ ➜  helm search repo apache
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/apache 11.2.17 2.4.62 Apache HTTP Server is an open-source HTTP serve...
bitnami/airflow 19.0.5 2.10.1 Apache Airflow is a tool to express and execute...

then pull it/ download

controlplane ~ ➜  helm pull bitnami/apache 

controlplane ~ ➜ ls
apache-11.2.17.tgz

Also we can download it with--untar option

controlplane ~ ➜  helm pull --untar bitnami/apache 

controlplane ~ ➜ ls
apache

In the above apache folder change replica to 2 and change nodePort to 30080 and try to install the helm package with release name mywebapp.

controlplane ~/apache is 📦 v11.2.17 via  v3.15.3   helm install mywebapp .
NAME: mywebapp
LAST DEPLOYED: Sat Sep 7 19:50:09 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: apache
CHART VERSION: 11.2.17
APP VERSION: 2.4.62

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

Testing if the change works

controlplane ~/apache is 📦 v11.2.17 via ⎈ v3.15.3 ➜  helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
mywebapp default 1 2024-09-07 19:50:09.138997116 +0000 UTC deployed apache-11.2.17 2.4.62


controlplane ~/apache is 📦 v11.2.17 via ⎈ v3.15.3 ✖ k get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mywebapp-apache-5f85d566bb-f579f 1/1 Running 0 62s 10.244.0.4 controlplane <none> <none>
mywebapp-apache-5f85d566bb-pkgjl 1/1 Running 0 62s 10.244.0.5 controlplane <none> <none>



controlplane ~ ➜ k get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
controlplane Ready control-plane 42m v1.30.0 192.28.30.9 <none> Ubuntu 22.04.4 LTS 5.4.0-1106-gcp containerd://1.6.26

controlplane ~ ➜ curl http://192.28.30.9:30080
<html><body><h1>It works!</h1></body></html>

Thank you for reading,
-Harish Pillai

Tidak ada komentar:

Posting Komentar