How to deploy K8 apps in k8 Cluster through Jenkins? - jenkins

I tried to use the Kubernetes Continuous Deploy Plugin but its seem it ran on the slave and deploy the app, but I want to deploy K8 Apps in K8 cluster not in jenkins slave.

As it described at wiki-pages you need configure access to your kubernetes cluster.
From documentation:
In the "Kubeconfig" dropdown, select the > kubeconfig stored in Jenkins.
in kubeconfig you store the access to your cluster, without this it would not work.

Related

Is there a serverless kubernetes datadog agent?

I have a unique type of Kubernetes cluster that cannot install the Kubernetes Datadog agent. I would like to collect the logs of individual docker containers in my Kubernetes pods similar to how the Docker agent works.
I am currently collecting docker logs from Kubernetes and then using a script with the Datadog custom log forwarder to upload them to Datadog. I was curious if there is a better way to achieve this serverless collection of docker logs from Kubernetes clusters in datadog? The ideal situation I want is to plug my kubeconfig somewhere and then let Datadog take care of the rest without deploying anything onto my Kubernetes cluster.
Is there an option for that outside of creating a custom script?
A better way would be to use a sidecar container with a logging agent, it won't increase the load on the API server.
Reference: https://kubernetes.io/docs/concepts/cluster-administration/logging/#sidecar-container-with-a-logging-agent
Datadog agent looks like doesn't support /suggest running as a sidecar (https://github.com/DataDog/datadog-agent/issues/2203#issuecomment-416180642)
I suggest looking at using other logging agent and pointing the backend to datadog.
Some options are:
fluentd: https://blog.powerupcloud.com/kubernetes-pod-management-using-fluentd-as-a-sidecar-container-and-prestop-lifecycle-hook-part-iv-428b5f4f7fc7
fluentd-bit: https://github.com/leahnp/fluentbit-sidecar
filebeat: https://www.elastic.co/beats/filebeat
Datadog supports them
https://docs.datadoghq.com/integrations/fluentd/
https://docs.datadoghq.com/integrations/filebeat/

How to handle "docker-in-docker" problem when using Jenkins inside K8S

New to Kubernetes, a little complex question needs help.
Background
Using Jenkins in GKE (Google Kubernetes Engine)
Want to use jenkins-docker plugin to provide the specific test environment for each type of tests
Don't want to mixin docker binary in the Jenkins image (because it is large)
Don't want docker-in-docker
More specifically, I don't want the Jenkins Pod be a new Docker Server
What I want
Each test environment can create a new pod in GKE Cluster, rather than creating containers inside the Jenkins Pod
P.S.
I have just read some articles, but half of them are telling about "how to use K8S to scale up the Jenkins (using jenkins-slave + jenkins-kubernates plugin)", another half are telling about how to "use docker plugin in a dockerized jenkins container on a bare metal machine (you can use /var/run/docker.sock to communicate between the host and the docker container)", but I cannot find **how to use docker plugin (to provide a specific environment) in a dockerized jenkins container inside K8S

Feasibility of Kubernetes helm deploying using Helm client from Jenkins pipeline job

I am trying to implement the Kubernetes service deployment using Kubernetes helm chart. Actually I am using Jenkins pipeline job for deployment. And Jenkins is installed out side of Kubernetes cluster. So If I am using Helm in the machine where Jenkins is installed , then can I use Helm deployment command inside on Jenkins pipeline job?
If I am calling "helm install" command inside one Jenkins pipeline job ? Does it deploy into remote Kubernetes cluster? Because I am installing Jenkins out side of Kubernetes cluster.
If I am calling "helm install" command inside one jenkins pipeline job
? Does it deploy into remote kubernetes cluster?
Yes. You need a ~/.kube/config file, network access to the k8s API, kubectl and helm to make it work.
Here's a good read explaining helm https://next.nutanix.com/kubernetes-containers-30/tillerless-helm-on-nutanix-karbon-31334

Kubernetes Jenkins connectivity Issue

I set up the kubernetes on EC2 instances over ubuntu platform, everything working fine. But now I have deployed a Jenkins pod, after that, I am able to access the Jenkins in the browser. Now my question is how can I connect Jenkins with my machine.
My Jenkins pod IP:- 10.43.0.8
My Kubernetes Master private IP:- 192.168.105.229
I am able to ping with each other. But how I can access my master machine using Jenkins, so I can create the pods through Jenkins.
There are a few ways to do this. A couple that I can think of:
Use the Jenkins Kubernetes Plugin. If you install this on your Jenkins master (which is also running on a pod) and also if you configure it to talk to the same Kubernetes cluster (meaning the kube-apiserver) then you can create/remove pods using the plugin. More on how to configure authentication and RBAC in Kubernetes
Manually configure Jenkins slaves running as 'user'. Then on the 'user's some directory create a ~/.kube/config that has the configuration to talk to your Kubernetes cluster. From there you can just issue kubectl commands to create/remove pods. You would still need to configure authentication/RBAC.
If you want to access a pod running in Kubernetes you need to expose it as a service and possibly an ingress resource
https://kubernetes.io/docs/concepts/services-networking/service/

How do I create a local kubernates cluster in a VM?

I have a set of docker images running in a Kubernates cluster on GKE. I have a Jenkins server running on a VM in GKE.
I have docker builds and GKE deploys running on the Jenkins server, but I would like to start up a 'local' cluster on the Jenkins server after successful builds, run my dockers in that cluster, run my tests towards the cluster, and then close down the local cluster before deploying the docker images to GKE.
I know about minikube, but they state that you are not able to run nested VM's, and I wonder if this blocks my dream of test my cluster before deploying it?
Do I have to run my local cluster on a physical server to be able to run my tests, or is there a solution to my problem?
Have you considered using kubeadm?
You can run a Kubernetes cluster within your Jenkins VM. Setup is a bit different than minikube and it's still in beta but it will let you test your cluster before the final deployment.

Resources