- Write your own declarative manifest to run a simple web application in a pod.
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
- Write your own
pod
manifest. - Apply the
pod
manifest. - Verify the
pod
is created correctly.
Step by step:
- 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:
- Find the API version for the
pod
resource in the Kubernetes API documentation and fill out theapiVersion
💡 Help me out!
The API version for the pod
resource is v1
- the
kind
should bePod
- the
name
should befrontend
for both the metadata and the spec - the
image
should beghcr.io/eficode-academy/quotes-flask-frontend:release
- the
containerPort
section should have5000
💡 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
Try to apply the manifest with kubectl apply -f frontend-pod.yaml
command.
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.
Delete the pod with kubectl delete pod frontend
command.
Congratulations! You have now learned how to make a manifest detailing our frontend pod.