Piszki Lab | EN

My case study in the clouds…

vSphere Integrated Containers 1.1.1 – create base image and push it into Harbor (and run container with persistent volume)

| 0 comments

For how to install and configure vSphere Integrated Containers I recently wrote here. Today we will create our own base docker image (with CentOS 7 system) with any application, and load it into the registry (image repository) on Harbor. In addition, we will create a persistent volume that will connect to our new container. The topic of VIC is quite new, so there is not much information on the Internet related to it, this article was created as an attempt to systematize the knowledge associated with it.

doc8

Why do we have to create our own base image of CentOS 7 when in the Docker Hub is available in stock? All images from the hub are cleared to zero, we will not find there simple things like the vi editor, curl, wget and others and which are sometimes useful. Of course, by putting our own applications we will use our own images, it is good to know how to create and manage them in vSphere environment using Harbor and Admiral. To make the base image, we will need a CentOS 7 machine. We do the following:

export image=/image/rootfs
mkdir -p $image
initialize rpm database
rpm –root $image –initdb

yum reinstall –downloadonly –downloaddir . centos-release
rpm –root $image -ivh centos-release*.rpm
rpm –root $image –import  $image/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

yum -y –installroot=$image –setopt=tsflags=’nodocs’ –setopt=override_install_langs=en_US.utf8 install yum

sed -i “/distroverpkg=centos-release/a override_install_langs=en_US.utf8\ntsflags=nodocs” $image/etc/yum.conf

cp /etc/resolv.conf $image/etc
chroot $image /bin/bash <<EOF
yum install -y procps-ng iputils vi mc bindutils wget curl (or what You want)
yum clean all
EOF
rm -f $image/etc/resolv.conf

If we need a proxy then we set it inside $image/etc/yum.conf. Now we have prepared the initial image, we import this image to local repo and run it as a container and see if everything works.

doc2

Our container works properly (for now locally on the machine where it was made) to run it on VCH we have to load it into Harbor. On a Linux machine, we create a directory with the name of the machine (VIC) to which we upload the ca.crt file, which is the certificate issued for Harbor (see the first VIC article). Then log into the Harbor to see if the communication is correct.

doc3

If everything is ok, we may copy the image from the local machine to Harbor repository (docker push command). In the remote repository is created the default project named library which we will use.

doc4

If everything is ok, we pull the container image from Harbor to VCH (VMware Container Host) and check that the image is properly visible.

doc5

Before we start the container, we will generate a persistent volumen and connect it to the container.

doc6

vCenter view:

doc7

We run our own CentOS 7 container with a persistent volume connected to the /etc directory so that our effects will not disappear after the container reboots. Of course, the whole procedure here is just an example of the possibilities that vSphere Integrated Containers brings.

Rate this article:
[Total: 1 Average: 5]

Author: Piotr Pisz

Computer always, since I got a Commodore 64 at the end of primary school, through his beloved Amiga and Linux infinite number of consoles, until today, fully virtual day. Since 2001, Unix/Linux Systems Administrator, for seven years a faithful companion and protector of Solaris system, until his sad end. In the year 2011 came in the depths of virtualization, then smoothly ascended into the clouds and continues there today. Professionally working as Systems Architect in the Polish Security Printing Works.

Leave a Reply

Required fields are marked *.


.

Enjoyed the post? Support Piszki Lab | EN, click on the AD! :-)

.