Improve documentations for Helm and FluxCD

In the current Helm documentation more details were added,
showing how to deploy an application using Helm.

Created a documentation to FluxCD showing how to deploy
an application using FluxCD resources.

Created a link in usertasks index to the new FluxCD documentation.

Fix merge conflict
Fix editorial issues

Closes-bug: 2068023

Change-Id: I20307dc98da4a9872ba441200499d4b3173d5f10
This commit is contained in:
Caio Fazio 2023-12-06 09:22:49 -03:00 committed by Elisamara Aoki Goncalves
parent ca0d5912cc
commit 68a49a940f
3 changed files with 202 additions and 8 deletions

View File

@ -57,6 +57,7 @@ Application management
:maxdepth: 1
kubernetes-user-tutorials-helm-package-manager
kubernetes-user-tutorials-fluxcd-deploy-00d5706c3358
---------------------
Local Docker registry

View File

@ -0,0 +1,132 @@
.. _kubernetes-user-tutorials-fluxcd-deploy-00d5706c3358:
=================
Deploy via FluxCD
=================
`FluxCD <https://fluxcd.io/>`__ is a continuous delivery tool for Kubernetes.
It is used to keep Kubernetes in sync with configuration sources such as Git
repositories.
|prod-long| does not have FluxCD CLI, but it does have `FluxCD resources
<https://fluxcd.io/flux/components/>`__ which can be used to deploy
applications.
Using FluxCD resources you can deploy your applications and apply GitOps to
them.
Create a Source Controller
**************************
The Source Controller is a FluxCD resource that serves as the pivotal point
for acquiring artifacts necessary for deployment. It is crucial for ensuring
easy access to important elements such as source code, configuration files,
and other essential components for deploying your application. Essentially, it
acts as the gateway facilitating the acquisition process, guaranteeing that
your application has the requisite resources for deployment.
There are five types of `Source Controllers
<https://fluxcd.io/flux/components/source/api/v1beta2/>`__, in this example
GitRepository will be used. The GitRepository is a type of Source Controller
that is used to manage applications defined within Git repositories.
In the active controller, run:
.. code-block:: none
cat <<EOF > gitrepository.yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: <source-controller-name>
spec:
interval: 5m
url: <git-repository-url>
ref:
branch: <branch>
EOF
.. code-block:: shell
$ kubectl apply -f gitrepository.yaml
The above command creates a GitRepository resource, you can check by running:
.. code-block:: shell
$ kubectl get gitrepositories
Create a Helm Controller
************************
For deploying applications via FluxCD, create a `Helm Controller
<https://fluxcd.io/flux/components/helm/>`__ or `Kustomize Controller
<https://fluxcd.io/flux/components/kustomize/>`__, each one has its
specifications.
For deploying via Helm, create a HelmRelease resource.
.. code-block:: none
cat <<EOF > helmrelease.yaml
apiVersion: "helm.toolkit.fluxcd.io/v2beta1"
kind: HelmRelease
metadata:
name: <helm-release-name>
spec:
releaseName: <helm-release-name>
interval: 5m
chart:
spec:
chart: <helm-chart-path> # Relative path of the Helm chart inside the repo.
version: <helm-chart-version>
sourceRef:
kind: GitRepository
name: <source-controller-name>
values: # Override values for the Helm chart.
foo:
bar: value
EOF
.. code-block:: shell
$ kubectl apply -f helmrelease.yaml
This command creates a HelmChart and a HelmRelease resources, the HelmChart
stores the Helm chart loaded from the GitRepository, and the HelmRelease is
responsible for applying Helm actions, such as configuring, installing or
upgrading the Helm Chart.
You can check if the resources were created by running:
.. code-block:: shell
$ kubectl get helmcharts
.. code-block:: shell
$ kubectl get helmreleases
To check the application deployment:
.. code-block:: shell
$ kubectl get all
-----------------------------
Modify the Application Values
-----------------------------
To modify values of your HelmRelease, you can edit the ``spec.values`` section
of ``helmrelease.yaml`` file and apply it again:
.. code-block:: shell
$ kubectl apply -f helmrelease.yaml
This will cause the controller to perform Helm actions on the deployment.

View File

@ -11,18 +11,79 @@ be used to securely manage the lifecycle of applications within the Kubernetes c
.. rubric:: |context|
Helm packages are defined by Helm charts with container information sufficient
for managing a Kubernetes application. You can configure, install, and upgrade
your Kubernetes applications using Helm charts. Helm charts are defined with a
default set of values that describe the behavior of the service installed
within the Kubernetes cluster.
Helm packages are defined by Helm charts which contain all of the Kubernetes
resource definitions necessary to run an application inside of a Kubernetes
cluster. In |prod|, you can configure, install, and upgrade your Kubernetes
applications using Helm charts.
|prod| recommends a non-admin end-user to install a Helm v3 client on a remote
workstation to enable management of their Kubernetes applications.
The Helm v3 client can be installed on a remote workstation and used to
remotely manage your Kubernetes application on |prod|, see :ref:`Security -
Access the System <index-security-kub-81153c1254c3>` and :ref:`Remote CLI
access <index-usertasks-kub-1291759aa985>`.
For more information on Helm, see the documentation at `https://helm.sh/docs/
<https://helm.sh/docs/>`__.
For more information on how to configure and use Helm both locally and remotely, see :ref:`Configure Local CLI Access <configure-local-cli-access>`,
For more information on how to configure and use Helm both locally and
remotely, see :ref:`Configure Local CLI Access <configure-local-cli-access>`,
and :ref:`Configure Remote CLI Access <configure-remote-cli-access>`.
---------------
Deploy via Helm
---------------
*********************
Use Helm Package File
*********************
You can use the packaged Helm chart from your development environment, and use
the `Helm CLI <https://helm.sh/docs/intro/install/>`__ to install the package.
#. Install your Helm package on |prod|
The command below, executed remotely or locally, will deploy the
application to the StarlingX-managed Kubernetes cluster:
.. code-block:: shell
$ helm install [ -f <myvalues.yaml-file> | --set <attribute-name>=<attribute-value> ] <appName> <package>.tgz
where:
The helm chart/application will be deployed with a default set of values;
unless those values are overridden with ``-f`` and/or ``--set`` options.
*******************
Use Helm Repository
*******************
Helm charts are defined with a default set of values that describe the behavior
of the service installed within the Kubernetes cluster.
You can install the helm application from a Helm charts repository
``<https://helm.sh/docs/helm/helm_repo/>``.
#. Add the URL for the Helm chart repository (containing the helm chart you
want to install) to the list of Helm chart repositories configured for your
helm client.
.. code-block:: shell
$ helm repo add <name> <helm-charts-repo-url>
.. code-block:: shell
$ helm repo update
#. Install the Helm application with the following command which will search
for the specified Helm chart in the configured Helm chart repositories, and
install it.
.. code-block:: shell
$ helm install [ -f <myvalues.yaml-file> | --set <attribute-name>=<attribute-value> ] <appName> <name>/<chart-name>
where:
The helm chart/application will be deployed with a default set of values;
unless those values are overridden with ``-f`` and/or ``--set`` options.