You are on page 1of 3

Create a file named pod-demo.

yaml with the following:


apiVersion: v1
kind: Pod
metadata:
name: demo-pod
labels:
app: demo-pod
type: frontend-app
spec:
containers:
- name: nginx-container
image: nginx

Now we can update our cluster-demo.yaml file to map our pods by their labels to
the ClusterIP service.
apiVersion: v1
kind: Service
metadata:
name: Backend
spec:
type: ClusterIP
ports:
- targerPort: 80
port: 80
selector:
name: demo-pod
type: frontend-app

Now that we have configured the YAML files, we have to:


1.Create and run our pods.
2.Create and run our ClusterIP service.
To run the pod, use the following command:
kubectl apply -f pod-demo.yaml

Next, let's create our service. Run the following command:


kubectl create -f cluster-ip-demo.yaml

Now that the pods are running inside our cluster, we will expose it to external traffic
using Kubernetes proxy.
Start the Kubernetes proxy using the following command:
kubernetes proxy --port=8080
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea comCreate a file named pod-demo.yaml with the following:
apiVersion: v1
kind: Pod
metadata:
name: demo-pod
labels:
app: demo-pod
type: frontend-app
spec:
containers:
- name: nginx-container
image: nginx

Now we can update our cluster-demo.yaml file to map our pods by their labels to
the ClusterIP service.
apiVersion: v1
kind: Service
metadata:
name: Backend
spec:
type: ClusterIP
ports:
- targerPort: 80
port: 80
selector:
name: demo-pod
type: frontend-app

Now that we have configured the YAML files, we have to:


1.Create and run our pods.
2.Create and run our ClusterIP service.
To run the pod, use the following command:
kubectl apply -f pod-demo.yaml

Next, let's create our service. Run the following command:


kubectl create -f cluster-ip-demo.yaml

Now that the pods are running inside our cluster, we will expose it to external traffic
using Kubernetes proxy.
Start the Kubernetes proxy using the following command:
kubernetes proxy --port=8080

modo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.

You might also like