Site icon i2tutorials

Kubernetes – Images

Kubernetes Images

 

We only support Kubernetes to support Docker images. Each pod has its Docker image running inside it. The building blocks of Containerized Infrastructure are Kubernetes (Docker) images.

Configuring a pod involves setting an image property in the configuration file, just like Docker commands. There’s a field to define the image name, which we’re going to pull from the registry.

Here is the common configuration structure for pulling images from Docker and deploying them to Kubernetes containers.

apiVersion: v1
kind: pod
metadata:
   name: Tesing_for_Image_pull -----------> 1
   spec:
      containers:
         - name: neo4j-server ------------------------> 2
         image: <Name of the Docker image>----------> 3
         imagePullPolicy: Always ------------->4
         command: ["echo", "SUCCESS"] ------------------->

The above code defines −

name: Tesing_for_Image_pull − Checks what container gets created after pulling images from Docker registry.

name: neo4j-server − Like we gave neo4j-server to the container we’re trying to create.

image: <Name of the Docker image> − Here’s the name of the image we’re trying to pull from Docker or our internal images registry. We need to define the whole registry path with the image name.

imagePullPolicy − Whenever we run this file to create a container, it’ll always pull the same image.

command: [“echo”, “SUCCESS”] − It will display a message when we access the container if everything goes well when we create the container.

Create a container by running the following command.

$ kubectl create –f Tesing_for_Image_pull

The output will be successful once we fetch the log.

$ kubectl log Tesing_for_Image_pull

We’ll get a success or failure output with the above command.

Note − Make sure you try all the commands.

 

Exit mobile version