Skip to content

Latest commit

 

History

History
133 lines (92 loc) · 2.97 KB

manifests.md

File metadata and controls

133 lines (92 loc) · 2.97 KB

Manifests

Learning Goals

  • Write your own declarative manifest to run a simple web application in a pod.

Introduction

Manifest files

A manifest describes the desired state of an object that you want Kubernetes to manage.

Manifests are described in yaml files and have the following general structure:

apiVersion:
kind:
metadata:
  labels:
spec:
💡 Extra: The general structure of a declarative manifest

The general structure of a manifest is like the following. This is not only for pods, but for all Kubernetes resources.

apiVersion: # Version of the API used for the kind/resource
kind: # The kind/resource or "type" of the object
metadata: # Metadata about the object
  name: # The name of the object (must be unique within this kind)
  labels: # Labels for the object (used for grouping, key-value pairs)
spec:# The desired state of the object
  # The spec varies depending on the kind/resource

Exercise

Overview

  • Write your own pod manifest.
  • Apply the pod manifest.
  • Verify the pod is created correctly.
Step by step:

Write your own pod manifest.

  • Go into the manifests/start directory.
  • Open the frontend-pod.yaml file in a text editor.

It looks like this:

apiVersion:
kind:
metadata:
  name:
spec:
  containers:
    - name:
      image:
      ports:
💡 Help me out!

The API version for the pod resource is v1

  • the kind should be Pod
  • the name should be frontend for both the metadata and the spec
  • the image should be ghcr.io/eficode-academy/quotes-flask-frontend:release
  • the containerPort section should have 5000
💡 Help me out!

The entire manifest should look like this:

apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
    - name: frontend
      image: ghcr.io/eficode-academy/quotes-flask-frontend:release
      ports:
        - containerPort: 5000

Apply the pod manifest.

Try to apply the manifest with kubectl apply -f frontend-pod.yaml command.

Verify the pod is created correctly.

Check the status of the pod with kubectl get pods command.

Expected output:

NAME       READY   STATUS    RESTARTS   AGE
frontend   1/1     Running   0          1m

Congratulations! You have now learned how to make a manifest detailing our frontend pod, and applied it to the cluster.

Clean up

Delete the pod with kubectl delete pod frontend command.

Congratulations! You have now learned how to make a manifest detailing our frontend pod.