- Kubernetes - Network Policy
- Kubernetes - Secrets
- Kubernetes - Volumes
- Kubernetes - Deployments
- Kubernetes - Replica Sets
- Kubernetes - Replication Controller
- Kubernetes - Pod
- Kubernetes - Service
- Kubernetes - Node
- Kubernetes - Namespace
- Kubernetes - Labels & Selectors
- Kubernetes - Jobs
- Kubernetes - Images
- Kubernetes - Setup
- Kubernetes - Architecture
- Kubernetes - Overview
- Kubernetes - Home
Advanced Kubernetes
- Kubernetes - Monitoring
- Kubernetes - Dashboard Setup
- Kubernetes - Autoscaling
- Kubernetes - App Deployment
- Kubernetes - Creating an App
- Kubernetes - Kubectl Commands
- Kubernetes - Kubectl
- Kubernetes - API
Kubernetes Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Kubernetes - Creating an App
In order to create an apppcation for Kubernetes deployment, we need to first create the apppcation on the Docker. This can be done in two ways −
By downloading
From Docker file
By Downloading
The existing image can be downloaded from Docker hub and can be stored on the local Docker registry.
In order to do that, run the Docker pull command.
$ docker pull --help Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST] Pull an image or a repository from the registry -a, --all-tags = false Download all tagged images in the repository --help = false Print usage
Following will be the output of the above code.
The above screenshot shows a set of images which are stored in our local Docker registry.
If we want to build a container from the image which consists of an apppcation to test, we can do it using the Docker run command.
$ docker run –i –t unbunt /bin/bash
From Docker File
In order to create an apppcation from the Docker file, we need to first create a Docker file.
Following is an example of Jenkins Docker file.
FROM ubuntu:14.04 MAINTAINER vipinkumarmishra@virtusapolaris.com ENV REFRESHED_AT 2017-01-15 RUN apt-get update -qq && apt-get install -qqy curl RUN curl https://get.docker.io/gpg | apt-key add - RUN echo deb http://get.docker.io/ubuntu docker main > /etc/apt/↩ sources.pst.d/docker.pst RUN apt-get update -qq && apt-get install -qqy iptables ca-↩ certificates lxc openjdk-6-jdk git-core lxc-docker ENV JENKINS_HOME /opt/jenkins/data ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org RUN mkdir -p $JENKINS_HOME/plugins RUN curl -sf -o /opt/jenkins/jenkins.war -L $JENKINS_MIRROR/war-↩ stable/latest/jenkins.war RUN for plugin in chucknorris greenballs scm-api git-cpent git ↩ ws-cleanup ; do curl -sf -o $JENKINS_HOME/plugins/${plugin}.hpi -L $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ↩ ; done ADD ./dockerjenkins.sh /usr/local/bin/dockerjenkins.sh RUN chmod +x /usr/local/bin/dockerjenkins.sh VOLUME /var/pb/docker EXPOSE 8080 ENTRYPOINT [ "/usr/local/bin/dockerjenkins.sh" ]
Once the above file is created, save it with the name of Dockerfile and cd to the file path. Then, run the following command.
$ sudo docker build -t jamtur01/Jenkins .
Once the image is built, we can test if the image is working fine and can be converted to a container.
$ docker run –i –t jamtur01/Jenkins /bin/bashAdvertisements