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

Bangalore Kubernetes Meetup April 2017

Like many Saturday mornings, Red Hat Bangalore office was once again abuzz with enthusiasm on 8th of April, for hosting yet another successful chapter of Bangalore Kubernetes Meetup. The Meetup had a good turnaround of about 40 people who gave up on their early morning saturday sleep to attend it despite the sweltering hot season and in line were four awesome talks. Suraj Deshmukh set the stage with his opening talk, Kubernetes on CRI-O, wherein he explained different jargons like OCI, CRI, etc., introduced CRI-O and it鈥檚 architecture. Explaining how it glues Kubernetes and OCI compliant runtimes and concluding it with a demo showing how Kubernetes uses CRI-O. Link to slides, video. ...

April 8, 2017 路 2 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

TODOs for new project

When starting a new open source project, apart from coding following are the things that need to be done. Docs README LICENSE How to install? How to use? Code of conduct guidelines Copyright Issue template like .github in repo. Developer docs How to install for developer? Developer docs Contribution guidelines Team meetings info Team communication channels Issue label guidelines Coding standards Code placement doc, or something that explains the way code is ordered Design document Development Makefile Unit tests Functional tests Coverage check CI for automatic tests Distro based package This is just few things that I could think of, please suggest if you know more in comments. ...

March 26, 2017 路 1 min 路 Suraj Deshmukh

rpm Notes

This post will get you through all the steps needed for doing RPM packaging. Setup of the system for building rpms $ dnf -y install fedora-packager fedora-review $ sudo usermod -a -G mock vagrant $ fedora-packager-setup $ kinit surajd@FEDORAPROJECT.ORG My Notes Start reading from: Fedora packager鈥檚 guide Some macros come from redhat-rpm-config and fedora-rpm-macros. $ sudo rpm -ql redhat-rpm-config-45-1.fc25.noarch To see all macros on the system: $ rpm --showrc Koji - fedora build system fedora uses fedpkg for doing builds, while rpmbuild is for CentOS To get general info about the package $ rpm -qip ./x86_64/namaskar-1-1.fc25.x86_64.rpm OR ...

March 24, 2017 路 2 min 路 Suraj Deshmukh

Git Notes

Notes about using git. Tips and tricks Switch branches $ git checkout <branch> status $ git status -sb Show status in short format and also give branch info show $ git show Shows log message and diff about the commit you are on. log $ git log -L 70,100:pkg/transformer/kubernetes/kubernetes.go Get logs on file between line numbers. $ git log --graph --abbrev-commit Show graph in logs. commit $ git add -p Commit only parts of file. Interactively choose chunks of patch. ...

March 21, 2017 路 8 min 路 Suraj Deshmukh