VMware Tanzu Modern Apps
  • Modern Application Solutions
  • The Why and What of Kubernetes
    • Introduction to Containers
    • Introduction to Kubernetes
    • From Docker Containers to Kubernetes
    • The Power of Kubernetes Services
    • Microservices Architecture
    • What is Cloud Native?
  • Build Kubernetes Runtime
    • Provisioning Kubernetes
      • Kubernetes on vSphere
        • Provisioning Kubernetes Clusters with VMware PKS
        • Provisioning Kubernetes Clusters with VMware Enterprise PKS
        • Provisioning Kubernetes Clusters with the Cluster API
    • Updating Kubernetes Clusters
    • Controlling Ingress with Contour
  • Manage and Monitor
    • Monitoring Kubernetes
    • Monitoring Containers at Scale with Wavefront
    • Monitoring with VMware vRealize Log Insight
    • Managing and Securing Container Images in a Registry
    • Compliance Testing with Sonobuoy
    • Backing Up, Restoring, and Migrating Resources with Velero
    • Managing Microservices with a Service Mesh
  • Multi-Cloud Multi-Cluster Management
  • Challenges Managing Multiple Cluster across Multiple Clouds
  • Introducing VMware Tanzu Mission Control
Powered by GitBook
On this page
  • Dockerfile to Create a Hello World Container Image
  • Creating a Kubernetes Deployment for Hello World

Was this helpful?

  1. The Why and What of Kubernetes

From Docker Containers to Kubernetes

Kubernetes helps schedule containers across a clusters of nodes. Docker is widely used to provide a container runtime as well as build and image management. Docker defines a standard format for packaging and porting software, much like ISO containers define a standard for shipping freight. As a runtime instance of a Docker image, a container consists of three parts:

  • A Docker image

  • An environment in which the image is executed

  • A set of instructions for running the image

After an application has been packaged to run in a container, it is a containerized application. A containerized application image along with a set of declarative instructions can be passed to Kubernetes to deploy the application. The containerized app instance running on the Kubernetes node derives the container runtime from the Kubernetes node along with compute, network, and possibly storage resources.

Let's walk-through what it takes to move a Docker container to a Kubernetes cluster.

  1. Create a container image from a Dockerfile

  2. Build a corresponding YAML file to define how Kubernetes deploys the app

Dockerfile to Create a Hello World Container Image

A manifest, called a Dockerfile, describes how the image and its parts are to run in a container on a host. To make the relationship between the Dockerfile and the image concrete, here’s an example of a Dockerfile that creates a "Hello World" app from scratch:

FROM scratch
COPY hello /
CMD ["/hello"]

When you give this Dockerfile to a local instance of Docker by using the docker buildcommand, it creates a container template with the "Hello World" app installed.

Creating a Kubernetes Deployment for Hello World

We then define a deployment manifest to tell Kubernetes how to run "Hello World" based on the container template:

#Hello World Deployment YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helloworld
spec:
  selector:
    matchLabels:
      app: hellowworld
  template:
    metadata:
      labels:
        app: helloworld
    spec:
      containers:
      - name: helloworld
        image: boskey/helloworld
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
PreviousIntroduction to KubernetesNextThe Power of Kubernetes Services

Last updated 5 years ago

Was this helpful?