connect from helm to kubernetes cluster - kubernetes

I have an application that is deployed on kubernetes cluster. Accessing this application using rancher namespace. By specifying this namespace I am getting "get pods", and all information.
Now, this application I want to control from the helm. what do I need to do?
I have installed helm where my kubectl installation is there.

If you want to "control" applications on Kubernetes cluster with Helm, you should start with helm charts. You can create some if one is not already available. Once you have chart(s), you can target the Kubernetes cluster with the cluster's KUBECONFIG file.
If I had a Helm chart like my-test-app and a Kubernetes cluster called my-dev-cluster.
With Helm I can:
deploy - install
helm install test1 my-test-app/ --kubeconfig ~/.kubeconfigs/my-dev-cluster.kubeconfig
update - upgrade
helm upgrade test1 my-test-app/ --kubeconfig ~/.kubeconfigs/my-dev-cluster.kubeconfig
remove - uninstall
helm uninstall test1 my-test-app/ --kubeconfig ~/.kubeconfigs/my-dev-cluster.kubeconfig
Where my-dev-cluster.kubeconfig is the kubeconfig file for my cluster in ~/.kubeconfigs directory. Or you can set the path using KUBECONFIG environment variable.

Related

Helm3 with EKS cluster

During Installation of Helm3 stable, i found Helm3 stable does not implement tiller deployment for fetching cluster details, it works as a Client utility only, my question is it, if it is not implementing tiller concept for fetching details, how does it connect with EKS.
I have already installed kubectl and it is running fine, is it something like this, helm client is dependent on kubectl service?
I performed following steps:
1.helm version
version.BuildInfo{Version:"v3.1.0", GitCommit:"b29d20baf09943e134c2fa5e1e1cab3bf93315fa", GitTreeState:"clean", GoVersion:"go1.13.7"}
2.kubectl create serviceaccount tiller --namespace kube-system
serviceaccount/tiller created
3.notepad rbac-config.yaml
4.kubectl apply -f rbac-config.yaml
clusterrolebinding.rbac.authorization.k8s.io/tiller-role-binding created
5.helm init --service-account tiller
Error: unknown flag: --service-account
I know steps 2,3,4 are not required in Helm3, but curious to know how helm3 interacts as a client service with EKS cluster.
Just like kubectl, helm also uses kubeconfig to communicate with the cluster.
So, both kubectl and helm depend on the cluster's config file rather depending on each other.

Role of Helm install command vs kubectl command in Kubernetes cluster deployment

I have a Kubernetes cluster with 1 master node and 2 worker node. And I have another machine where I installed Helm. Actually I am trying to create Kubernetes resources using Helm chart and trying to deploy into remote Kubernetes cluster.
When I am reading about helm install command, I found that we need to use helm and kubectl command for deploying.
My confusion in here is that, when we using helm install, the created chart will deploy on Kubernetes and we can push it into chart repo also. So for deploying we are using Helm. But why we are using kubectl command with Helm?
Helm 3: No Tiller. Helm install just deploys stuff using kubectl underneath. So to use helm, you also need a configured kubectl.
Helm 2:
Helm/Tiller are client/server, helm needs to connect to tiller to initiate the deployment. Because tiller is not publicly exposed, helm uses kubectl underneath to open a tunnel to tiller. See here: https://github.com/helm/helm/issues/3745#issuecomment-376405184
So to use helm, you also need a configured kubectl. More detailed: https://helm.sh/docs/using_helm/
Chart Repo: is a different concept (same for helm2 / helm3), it's not mandatory to use. They are like artifact storage, for example in quay.io application registry you can audit who pushed and who used a chart. More detailed: https://github.com/helm/helm/blob/master/docs/chart_repository.md. You always can bypass repo and install from src like: helm install /path/to/chart/src

Deploying Images from gitlab in a new namespace in Kubernetes

I have integrated gitlab with Kubernetes cluster which is hosted on AWS. Currently it builds the code from gitlab to the default namespace. I have created two namespaces in kubernetes one for production and one for development. What are the steps if I want that to be deployed in a dev or a production namespace. Do I need to make changes at the gitlab level or on the kubernetes level.
This is done at the kubernetes level. Whether you're using helm or kubectl, you can specify the desired namespace in the command.
As in:
kubectl create -f deployment.yaml --namespace <desired-namespace>
helm install stable/gitlab-ce --namespace <desired-namespace>
Alternatively, you can just change your current namespace to the desired namespace and install as you did before. By default, helm charts or kuberenetes yaml files will install into your current namespace unless specified otherwise.

How to install spinnaker on local kubernetes cluster

I'm trying to install spinnaker on local kubernetes cluster.
I found some guide at https://github.com/kenzanlabs/spinikube but this guide is out of date. Now all install and config spinnaker via halyard.
I also found this guide https://www.spinnaker.io/setup/quickstart/halyard-gke/ to deploy spinnaker on google kubernetes cloud using google storage.
But I have local kubernetes cluster on my data center, and I configured storageclass (via heketi and glusterfs) to persistent storage. Now I want to install spinnaker on my local cluster.
So can halyard support install spinnaker on local kubernetes cluster?
I would look at using Helm for this. Helm is a package manager for Kubernetes that makes installing applications in your cluster very easy.
Helm uses a packaging format called charts. A chart is basically a collection of files that describe a related set of Kubernetes resources.
There is a Spinnaker Helm Chart available here that will install all Spinnaker services into your cluster with one command.
helm install --name my-spinnaker stable/spinnaker

Kubernetes helm - Running helm install in a running pod

I want to spin up a single installer pod with helm install that once running, will apply some logic and install other applications into my cluster using helm install.
I'm aware of the helm dependencies, but I want to run some business logic with the installations and I'd rather do it in the installer pod and on the host triggering the whole installation process.
I found suggestions on using the Kubernetes REST API when inside a pod, but helm requires kubectl installed and configured.
Any ideas?
It seems this was a lot easier than I thought...
On a simple pod running Debian, I just installed kubectl, and with the default service account's secret that's already mounted, the kubectl was already configured to the cluster's API.
Note that the configured default namespace is the one that my installer pod is deployed to.
Verified with
$ kubectl cluster-info
$ kubectl get ns
I then installed helm, which was already using the kubectl to access the cluster for installing tiller.
Verified with
$ helm version
$ helm init
I installed a test chart
$ helm install --name my-release stable/wordpress
It works!!
I hope this helps
You could add kubectl to your installer pod.
"In cluster" credentials could be provided via service account in "default-token" secret: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/