...
Info | ||
---|---|---|
| ||
When you execute the command kubectl expose deployment <deployment name> --type=LoadBalancer --port=<port>, you do not need to use a port value of 80 when another service is going to use this service. The only reason we have used 80 here is because we want to view the service via a browser. |
Worked Example
Begin by creating a yaml file
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
apiVersion: apps/v1
kind: Deployment
metadata:
name: shw
labels:
run: hw
spec:
replicas: 1
selector:
matchLabels:
run: hw
template:
metadata:
labels:
run: hw
spec:
containers:
- image: kathequian/helloworld
name: shw
ports:
- containerPort: 80 |
The service and deployment name is shw as shown on line 4
Execute the following command
Now use the get pods and get deployments commands to see what has been created
Notice the name of the pod, it has a unique ID appended to the deployment name
The service is not available to the outside world until it is exposed with the kubectl expose deployment <deployment name> command