hi @Ayman
In Kubernetes for absolute beginners
Section : Services
Lab : Q 10
I am able to modify the service-definition-1.yaml file but the service does not get created.
Why does it says " The Service “service-definition-1.yaml” is invalid " ?
Can you please review and help by identifying what is the mistake or error from my end ?
=============================
Question
Create a new service to access the web application using the service-definition-1.yaml file
Name: webapp-service; Type: NodePort; targetPort: 8080; port: 8080; nodePort: 30080; selector: simple-webapp
Check
- info_outline Hint
Update the given values in the service definition file and create the service
========================================================
Terminal Output
master $
master $ kubectl create service nodeport service-definition-1.yaml
error: at least one tcp port specifier must be provided
master $
master $ kubectl create service nodeport service-definition-1.yaml --tcp=30080:8080
The Service “service-definition-1.yaml” is invalid: metadata.name: Invalid value: “service-definition-1.yaml”: a DNS-1035 label must consist of lower case alphanumeric characters or ‘-’, start with an alphabetic character, and end with an alphanumeric character (e.g. ‘my-name’, or ‘abc-123’, regex used for validation is ‘a-z?’)
master $ cat service-definition-1.yaml
apiVersion: v1
kind: Service
metadata:
name: webapp-service
spec:
type: NodePort
ports:
- targetPort: 8080
port: 8080
nodePort: 30080
selector:
name: simple-webapp
master $
master $ date
Thu Jul 9 07:14:21 UTC 2020
master $
master $ pwd
/root
master $
master $ ls
Desktop go service-definition-1.yaml
master $
master $ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/simple-webapp-deployment-677668f6b-2qfhm 1/1 Running 0 17m
pod/simple-webapp-deployment-677668f6b-5b9lb 1/1 Running 0 17m
pod/simple-webapp-deployment-677668f6b-ftf82 1/1 Running 0 17m
pod/simple-webapp-deployment-677668f6b-rxb7w 1/1 Running 0 17m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 24m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/simple-webapp-deployment 4/4 4 4 17m
NAME DESIRED CURRENT READY AGE
replicaset.apps/simple-webapp-deployment-677668f6b 4 4 4 17m
master $
============================================================
Checks
- Tasks not completed!