Introduction
Today we will learn to expose the Pod Resource of Kubernetes.
Expose Pod
We will create and expose the pod using below yaml:
apiVersion: v1
kind: Pod
metadata:
name: ashok-pod
labels:
app: web
spec:
containers:
- name: hello-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: ashok-svc
spec:
type: LoadBalancer
ports:
- port: 8080
targetPort: 8080
selector:
app: webWe will create the pod and service using:
$ kubectl apply -f pod2.yaml pod/ashok-pod created service/ashok-svc created
We can status using below:
$ kubectl get all NAME READY STATUS RESTARTS AGE pod/ashok-pod 1/1 Running 0 92s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/ashok-svc LoadBalancer 10.108.156.134 <pending> 8080:30901/TCP 92s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3d2h
Create a tunnel to access service in browser:
$ minikube tunnel 🏃 Starting tunnel for service ashok-svc.
Happy Coding !!

No comments:
Post a Comment