Skip to content

Instantly share code, notes, and snippets.

View vishnuhd's full-sized avatar
🎯
Focusing

Vishnu Hari Dadhich vishnuhd

🎯
Focusing
View GitHub Profile
@vishnuhd
vishnuhd / Accessing k8s dashboard
Created July 8, 2019 15:27
Command to get token to login into the K8s Dashboard
kubectl -n kube-system describe secrets \
`kubectl -n kube-system get secrets | awk '/clusterrole-aggregation-controller/ {print $1}'` \
| awk '/token:/ {print $2}'
@vishnuhd
vishnuhd / Display pods and nodes
Last active March 15, 2021 07:49
Display pods and nodes they are deployed on side by side
kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --sort-by="{.spec.nodeName}" --all-namespaces
@vishnuhd
vishnuhd / publicIP.sh
Last active July 26, 2019 08:42
Get your public IP address
curl ipinfo.io/ip
curl ifconfig.me
@vishnuhd
vishnuhd / setup-helm-tiller.md
Last active August 8, 2019 11:53
setup helm tiller

Install Helm using the Helm installation instructions.

  • Create an RBAC service account.
kubectl create serviceaccount tiller -n kube-system
  • Bind the cluster-admin role to the service account.
kubectl create clusterrolebinding tiller \
--clusterrole=cluster-admin \
@vishnuhd
vishnuhd / localstorage-docker-desktop.md
Last active August 20, 2019 09:00
To create a persistent volume on local hard drive with docker-desktop

StorageClass

apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
metadata:
  name: localstorage
provisioner: docker.io/hostpath
@vishnuhd
vishnuhd / jenkins-on-docker.md
Last active September 7, 2019 21:28
Quickly get a Jenkins server running locally on docker with persistent volume

Command :

docker run -d -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

PS :

Docker should be installed on the host machine.

@vishnuhd
vishnuhd / docker-desktop-k8s-local-image.md
Created August 22, 2019 13:17
Reference local images in Docker for Mac - Kubernetes

Reference local images in Docker for Mac - Kubernetes

To run a local baked docker image in docker for mac kubernetes set the imagePullPolicy to Never.

For example:

apiVersion: v1
kind: Pod
metadata:
 name: local-image-test
@vishnuhd
vishnuhd / mysql-client-k8s.md
Created August 22, 2019 13:21
mysql-client in Kubernetes to test your connection to mysql server

mysql-client in Kubernetes to test your connection to mysql server

kubectl run mysql-client --image=mysql:5.7 -it --rm --restart=Never -- /bin/bash

mysql -h mysql-service -uroot -proot_password -e 'SHOW databases;'

OR

mysql -h mysql-service -uroot -proot_password

@vishnuhd
vishnuhd / readme.md
Last active September 3, 2019 07:28
Controller | Custom Controller | Operator

Since CoreOS coined the term "Operator", their article is the authority on what they mean by that:

An Operator is an application-specific controller that extends the Kubernetes API to create, configure and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and controller concepts, but also includes domain or application-specific knowledge to automate common tasks better managed by computers.

We use Operators because managing stateful applications, like databases, caches and monitoring systems, is a big challenge, especially at massive scale. These systems require human operational knowledge to correctly scale, upgrade and reconfigure while at the same time protecting against data loss and unavailability.

To paraphrase: All Operators use the controller pattern, but not all controllers are Operators. It's only an Operator if it's got: controller pattern + API extension + single-app focus.

TfJob is a good example of an Operator,

@vishnuhd
vishnuhd / readme.md
Created September 3, 2019 11:15
Create Jenkins pipeline using REST api and CURL
  • Get the config.xml from a pre-created job or create another one according to the need :
➜  curl -X GET http://localhost:8080/job/test-pipeline/config.xml -u admin:admin -o config.xml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1599  100  1599    0     0  18518      0 --:--:-- --:--:-- --:--:-- 18593
  • Generate Crumb :
➜ CRUMB=$(curl -s 'http://localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)' -u admin:admin)