-
Edit your previously created YAML file "nginx-pod.yaml" with the following criteria:
a.) a label "app: nginx"
b.) expose the container port 80
-
Create the Pod
-
Enter the Pod's shell
-
Echo "connection successful" to /usr/share/nginx/html/index.html
-
Exit the shell
-
Create a YAML file named "nginx-service.yaml" with the following criteria:
a.) the kind is set to Service
b.) a label "app: nginx"
c.) port set to 80 and a protocol of TCP
d.) selector set to "app:nginx"
-
Create the service resouce within the cluster
-
Check that the service is running
-
Inspect the service and note the IP address & TargetPort
-
Curl the service's <IP_Address:TargetPort>
-
Delete the resources created
-
apiVersion: v1 kind: Pod metadata: name: nginx-test labels: app: nginx spec: volumes: - name: data emptyDir: {} containers: - name: nginx image: nginx volumeMounts: - name: data mountPath: /usr/share/nginx/html ports: - containerPort: 80 -
oc create -f nginx-pod.yaml -
oc exec -it nginx-test /bin/bash -
echo connection successful > /usr/share/nginx/html/index.html -
exit -
apiVersion: v1 kind: Service metadata: name: nginx-test labels: app: nginx spec: ports: - port: 80 protocol: TCP selector: app: nginx -
oc create -f nginx-service.yaml -
oc get service -
oc describe service/nginx-test.yaml -
curl <IP_address:TargetPort> -
oc delete -f nginx-podkubectl delete -f nginx-service