How many Services exist on the system? in the current(default) namespace

k get svc -o wide
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE     SELECTOR
kubernetes   ClusterIP   10.43.0.1    <none>        443/TCP   3m14s   <none>

<aside> 💡 That is a default service created by Kubernetes at launch.

</aside>

What is the type of the default kubernetes service?

k get svc -o wide
NAME         **TYPE**        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE     SELECTOR
kubernetes   **ClusterIP**   10.43.0.1    <none>        443/TCP   3m14s   <none>

What is the targetPort configured on the kubernetes service? 6443

k get svc -o wide
	NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE     SELECTOR
	kubernetes   ClusterIP   10.43.0.1    <none>        443/TCP   4m45s   <none>

k describe svc kubernetes 
	Name:              kubernetes
	Namespace:         default
	Labels:            component=apiserver
	                   provider=kubernetes
	Type:              ClusterIP
	IP Family Policy:  SingleStack
	IP Families:       IPv4
	IP:                10.43.0.1
	IPs:               10.43.0.1
	Port:              https  443/TCP
	**TargetPort:        6443/TCP**
	Endpoints:         10.31.128.9:6443

k get svc kubernetes -o yaml
	apiVersion: v1
	kind: Service
	metadata:
	  labels:
	    component: apiserver
	    provider: kubernetes
	  name: kubernetes
	  namespace: default
	spec:
	  clusterIP: 10.43.0.1
	  clusterIPs:
	  - 10.43.0.1
	  internalTrafficPolicy: Cluster
	  ipFamilies:
	  - IPv4
	  ipFamilyPolicy: SingleStack
	  ports:
	  - name: https
	    port: 443
	    protocol: TCP
	    **targetPort: 6443**
	  sessionAffinity: None
	  type: ClusterIP

How many labels are configured on the kubernetes service? 2

k get svc --show-labels
NAME        TYPE       CLUSTER-IP  EXTERNAL-IP  PORT(S)  LABELS
kubernetes  ClusterIP  10.43.0.1   <none>       443/TCP  component=apiserver,
																												 provider=kubernetes

How many Endpoints are attached on the kubernetes service? 1

k describe svc kubernetes 
	Name:              kubernetes
	Namespace:         default
	Labels:            component=apiserver
	                   provider=kubernetes
	Annotations:       <none>
	Selector:          <none>
	Type:              ClusterIP
	IP Family Policy:  SingleStack
	IP Families:       IPv4
	IP:                10.43.0.1
	IPs:               10.43.0.1
	Port:              https  443/TCP
	TargetPort:        6443/TCP
	**Endpoints:         10.31.128.9:6443**
	Session Affinity:  None
	Events:            <none>

k get endpoints
	NAME         ENDPOINTS          AGE
	kubernetes   10.31.128.9:6443   10m

k describe endpoints kubernetes 
	Name:         kubernetes
	Namespace:    default
	Labels:       endpointslice.kubernetes.io/skip-mirror=true
	Annotations:  <none>
	Subsets:
	  Addresses:          10.31.128.9
	  NotReadyAddresses:  <none>
	  Ports:
	    Name   Port  Protocol
	    ----   ----  --------
	    https  6443  TCP

How many Deployments exist on the system now? in the current(default) namespace. 1

k get deployments.apps simple-webapp-deployment 
NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
simple-webapp-deployment   4/4     4            4           97s

What is the image used to create the pods in the deployment?

k get deploy -o wide
NAME           CONTAINERS     **IMAGES**                     
simple-webapp  simple-webapp  **kodekloud/simple-webapp:red** 

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:

name: simple-webapp

# --tcp=<port>:<targetPort>
k create service nodeport \\
webapp-service \\
--tcp=8080:8080 \\
--node-port=30080 \\
--dry-run=client -o yaml > svc.yaml

	apiVersion: v1
	kind: Service
	metadata:
	  labels:
	    app: webapp-service
	  name: webapp-service
	spec:
	  ports:
	  - name: 8080-8080
	    nodePort: 30080
	    port: 8080
	    protocol: TCP
	    targetPort: 8080
	  **selector:
	    app: webapp-service**
	  type: NodePort

Ajustar o selctor para
	  **selector:
	    name: simple-webapp**

k get svc webapp-service -o yaml
	apiVersion: v1
	kind: Service
	metadata:
	  labels:
	    app: webapp-service
	  name: webapp-service
	  namespace: default
	spec:
	  clusterIP: 10.43.34.107
	  clusterIPs:
	  - 10.43.34.107
	  externalTrafficPolicy: Cluster
	  internalTrafficPolicy: Cluster
	  ipFamilies:
	  - IPv4
	  ipFamilyPolicy: SingleStack
	  ports:
	  - name: 8080-8080
	    nodePort: 30080
	    port: 8080
	    protocol: TCP
	    targetPort: 8080
	  selector:
	    name: simple-webapp
	  sessionAffinity: None
	  type: NodePort