install helm chart package without public container registry (offline,locally) - kubernetes

My problem is when i want to install a package in kubernetes cluster with helm chart, for example install gitlab with helm, during installation there is need to download docker image from a public registry and i don't access internet and i ran nexus repository in my local environment but in helm chart i can't set my local nexus docker image repository as a registry to helm and helm try to download docker image from internet not my local repository.
how can i set my local nexus repository as a primary docker registry for helm chart?
in helm chart this is difficult to change instruction of a ready to use helm chart, for example gitlab helm chart, and you can only download docker images independently and if PullPolicyImage set to IfNotPresent image does not download again.
you can change helm chart ready to use repo, to download images from you local repo with adding your local_registryIP:Port in front of a docker image address. but as i said this difficult for large helm chart like gitlab.

Related

Difference between helm repo add vs helm install

I have delved into the documentations of helm and still it is unclear what is the difference between the two. Here's what I understand so far
helm install -> install a helm chart
helm repo add -> add a repo from the internet
You can see Helm as a templating tool, which reads files from the templates directory, fills them with values from values.yaml, and deploys them into the Kubernetes cluster. These is all done by the helm install command. So, Helm install takes your chart and deploys it into the Kubernetes cluster.
One of the feature of Helm is helm package, which packages your chart into a single *.tgz file and then you can store it in the Helm registry. A lot of Helm charts are stored that way, you can look, e.g., into Artifact Hub. If you find a chart you'd like to install from the Helm registry, you can add that remote repo into your local Helm registry using helm repo add. Then, helm repo update downloads a Helm chart to your local registry. Downloading a repo just downloads the Helm chart into your local registry, but it does not deploy anything into the Kubernetes cluster. To do that, you need to use helm install.

How can I use Gitlab's Container Registry for Helm Charts with ArgoCDs CI/CD Mechanism?

My situation is as follows:
have a kubernetes cluster with a couple of nodes
have argocd installed on the cluster and working great
using gitlab for my repo and build pipelines
have another repo for storing my helm charts
have docker images being built in gitlab and pushed to my gitlab registry
have argocd able to point to my helm chart repo and sync the helm chart with my k8s cluster
have helm chart archive files pushed to my gitlab repo
While this is a decent setup, it's not ideal.
The first problem i faced with using a helm chart git repo is that I can't (or don't know) how to differentiate my staging environment with my production environment. Since I have a dev environment and prod environment in my cluster, argocd syncs both environments with the helm chart repo. I could get around this with separate charts for each environment but that isn't a valid solution.
The second problem i faced, while trying to get around the above problem, is that I can't get argocd to pull helm charts from a gitlab oci registry. I made it so that my build pipeline pushed the helm chart archive file to my gitlab container registry with the tag dev-latest or prod-latest, which is great, just what I want. The problem is that argocd, as far as I can tell, can't pull from gitlab's container registry.
How do I go about getting my pipeline automated with gitlab as my repo and build pipeline, helm for packaging my application, and argocd for syncing my helm application with my k8s cluster?
is that I can't get argocd to pull helm charts from a gitlab oci registry.
You might be interested by the latest Jul. 2021 GitLab 14.1:
Build, publish, and share Helm charts
Helm defines a chart as a Helm package that contains all of the resource definitions necessary to run an application, tool, or service inside of a Kubernetes cluster.
For organizations that create and manage their own Helm charts, it’s important to have a central repository to collect and share them.
GitLab already supports a variety of other package manager formats.
Why not also support Helm? That’s what community member and MVP from the 14.0 milestone Mathieu Parent asked several months ago before breaking ground on the new GitLab Helm chart registry. The collaboration between the community and GitLab is part of our dual flywheel strategy and one of the reasons I love working at GitLab. Chapeau Mathieu!
Now you can use your GitLab project to publish and share packaged Helm charts.
Simply add your project as a remote, authenticating with a personal access, deploy, or CI/CD job token.
Once that’s done you can use the Helm client or GitLab CI/CD to manage your Helm charts.
You can also download the charts using the API or the user interface.
What’s next? First, we’d like to present additional metadata for charts.
Then we’ll start dogfooding the feature by using it as a replacement for https://charts.gitlab.io/.
So, try out the feature and let us know how it goes by commenting in the epic GitLab-#6366.
See Documentation and issue.

How to tell Helm which repo & chart is going to install?

I'm following Helm's document here to install a package, a.k.a. a helm chart:
$ helm install happy-panda stable/mariadb
It's really convenient to have a ready-to-use package. But in case of a package doesn't belong to stable repo, for example appmesh-grafana then I have to do more than this:
$ helm repo add aws https://aws.github.io/eks-charts
$ helm install aws/appmesh-grafana --version 0.1.0
Therefore, it forces me surf around the internet to find repo url, package name, etc. I don't want to do it every single time!
Is there any way to specify the repo and chart to install using Chart.yaml? I prefer Chart.yaml than shell script.
The short answer is no, if a chart is not in the official repo, then you always need to add the repository first before installing the chart.
However, starting from the Helm 3, you can look for the chart directly in the Helm Hub. In your case, if you wanted to find appmesh-grafana, you can execute the following command.
$ helm search hub appmesh-grafana
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/aws/appmesh-grafana 0.1.0 6.4.3 App Mesh Grafana Helm chart for Kubernetes
But then, yes, you need to open the link, find the address, and anyway execute $ helm repo add aws https://aws.github.io/eks-charts.

How can I use private helm repository with Spinnaker?

I want to use Artifactory as private Helm repository and deploy my app using helm chart to Kubernetes everytime a new version of helm chart gets uploaded to Artifactory.
Yes, you can do it. You can find more information about it here
The Helm charts repo is a web server that serves files, it could also be something like Amazon S3 or Google Cloud Storage bucket and then you can add an index.yaml file and then all your charts. So you could also integrate that with Spinnaker.

What format is custom Helm chart repository?

I am installing Kubernetes in a non-internet environment. I want to use Helm and want to set up a custom chart repository.
helm init barfs after creating ~/.helm/repository/repositories.yaml as it can't reach the default Google repo, so I will end up installing manually via kubectl - what is the format of this chart repository if I want to set up my own?
I will run helm init --dry-run --debug in order to get the manifest and amend this to point at a Docker registry that I have access to then install via kubectl.
I didn't see the section in the docs here: https://github.com/kubernetes/helm/blob/master/docs/chart_repository.md
It's a web server.
A custom helm repository doesnt have to do anything with your kubernetes. Setting up the custom repo can be done without connecting even to any kubernetes cluster.
helm init --client-only
Next step is to set up your custom repository somewhere like a storage account or whatever, then add that custom repo Url to your helm. So far this is all client side; you didnt touch your cluster yet.
helm repo add <HELM-REPO-NAME> <HEM-REPO-URL>
The final step which is where you will need to connect to a real kubernetes cluster to install the helm chart using Tiller which lives inside your cluster.