Change namespaces in Kubernetes

There is no easy way to change namespace in Kubernetes using kubectl command line utility. But here are some commands that you can alias in your bashrc file so that it鈥檚 just a single command that you can use to change the namespace in the Kubernetes cluster. Change namespace Let鈥檚 see step by step what goes in to change the namespace. So the first step is to find the context. A context element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, the kubectl command-line tool uses parameters from the current context to communicate with the cluster. Read more. ...

July 2, 2018 路 3 min 路 Suraj Deshmukh

Using private container registries from minikube

I am doing Kubernetes native development using minikube. And for doing that I had to download a Container image that is available in internally hosted private container registry. On the configuration side of doing that you will need to create Kubernetes Secret of type docker-registry. And now refer that secret you just created in your Pod manifest under pod.spec.imagePullSecrets. For more info follow the tutorial in Kubernetes docs on Pull an Image from a Private Registry. ...

October 6, 2017 路 2 min 路 Suraj Deshmukh

Static Pods using Kubelet on Fedora

I wanted to try out Standalone Kubelet Tutorial of Kelsey Hightower by myself but I could not follow it as it is, because it was firstly on GCE and secondly it uses CoreOS, but since I am very familiar to Fedora I thought of following that tutorial on it. To get a quick setup of a fresh Fedora machine use Vagrant. I have used Vagrantfile available here. This blog is only replacement of section Install the Standalone Kubelet in tutorial. ...

September 23, 2017 路 2 min 路 Suraj Deshmukh

Kubernetes Learning resources

Following is the list of all the places you can learn Kubernetes from: Scalable Microservices with Kubernetes - Video tutorial Fundamentals of Containers, Kubernetes, and Red Hat OpenShift - Video tutorial Kubernetes By Example - DIY tutorial Learn Kubernetes using Interactive Browser-Based Scenarios - DIY tutorial in your own web browser Interactive Learning Portal for OpenShift - DIY tutorial in your own web browser Kubernetes docs - Textual DIY docs Kubernetes API reference v1.6 OpenShift docs - Textual DIY docs

August 17, 2017 路 1 min 路 Suraj Deshmukh

Enabling local development with Kubernetes

I want to show how you can enable Kubernetes in your day to day development workflow. So that you get the feel of production deployment locally from day 1. I have a flask application which I am working on. The basic directory structure looks like this: $ ll total 24 -rw-rw-r--. 1 foo foo 427 Apr 23 16:23 app.py -rw-rw-r--. 1 foo foo 201 Apr 23 16:55 docker-compose.yml -rw-rw-r--. 1 foo foo 363 Apr 23 16:21 Dockerfile -rwxrwxr-x. 1 foo foo 82 Dec 5 19:41 entrypoint.sh -rw-rw-r--. 1 foo foo 3010 Dec 5 19:41 README.adoc -rw-rw-r--. 1 foo foo 11 Dec 5 19:41 requirements.txt You can find all of these files in this github repo. ...

April 23, 2017 路 5 min 路 Suraj Deshmukh

Quick PV for local Kubernetes cluster

I do lot of Kubernetes related work either on minikube or local OpenShift cluster setup in a VM. Often I need to create a PersistentVolumeClaim a.k.a. pvc. But to use pvc you have to have a PersistentVolume or pv defined. Enter into the machine running k8s If using minikube you can do minikube ssh Create a local directory for storage mkdir /tmp/pv0001 chmod 777 /tmp/pv0001 If you are on a machine that has SELinux enabled do the following ...

April 18, 2017 路 1 min 路 Suraj Deshmukh

k8s on CRI-O - single node

Here is a single node Kubernetes on CRI-O. This setup is done on Fedora 25. Installing OS dependencies dnf -y install \ go \ git \ btrfs-progs-devel \ device-mapper-devel \ glib2-devel \ glibc-devel \ glibc-static \ gpgme-devel \ libassuan-devel \ libgpg-error-devel \ libseccomp-devel \ libselinux-devel \ pkgconfig \ wget \ etcd \ iptables Creating go environment cd ~ mkdir -p ~/go export GOPATH=~/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN echo 'GOPATH=~/go' >> ~/.bashrc echo 'GOBIN=$GOPATH/bin' >> ~/.bashrc echo 'PATH=$PATH:$GOBIN' >> ~/.bashrc Pull all the code dependencies go get -d k8s.io/kubernetes go get -u github.com/cloudflare/cfssl/cmd/... Install runc go get -d github.com/opencontainers/runc cd $GOPATH/src/github.com/opencontainers/runc git reset --hard v1.0.0-rc3 make BUILDTAGS='seccomp selinux' && make install Build cri-o cd go get -d github.com/kubernetes-incubator/cri-o cd $GOPATH/src/github.com/kubernetes-incubator/cri-o make install.tools make && make install make install.config Set up CNI go get -d github.com/containernetworking/cni cd $GOPATH/src/github.com/containernetworking/cni ./build.sh mkdir -p /opt/cni/bin cp bin/* /opt/cni/bin/ mkdir -p /etc/cni/net.d/ cat > /etc/cni/net.d/10-ocid-bridge.conf <<EOF { "cniVersion": "0.2.0", "name": "ocid-bridge", "type": "bridge", "bridge": "cni0", "isGateway": true, "ipMasq": true, "ipam": { "type": "host-local", "subnet": "10.88.0.0/16", "routes": [ { "dst": "0.0.0.0/0" } ] } } EOF cat > /etc/cni/net.d/99-loopback.conf <<EOF { "cniVersion": "0.2.0", "type": "loopback" } EOF Create policy.json mkdir -p /etc/containers cat > /etc/containers/policy.json <<EOF { "default": [ { "type": "insecureAcceptAnything" } ] } EOF Make SELinux happy mkdir -p /var/lib/containers/ chcon -Rt svirt_sandbox_file_t /var/lib/containers/ Start ocid service export PATH=$PATH:/usr/local/bin/ echo 'PATH=$PATH:/usr/local/bin/' >> ~/.bashrc ocid --runtime /usr/local/sbin/runc --log /root/ocid.log --debug --selinux true Start k8s cluster with crio cd $GOPATH/src/k8s.io/kubernetes/ CONTAINER_RUNTIME=remote CONTAINER_RUNTIME_ENDPOINT='/var/run/ocid.sock --runtime-request-timeout=15m' ./hack/local-up-cluster.sh To use kubectl (in new terminal) ...

April 8, 2017 路 2 min 路 Suraj Deshmukh