본문 바로가기

CKA &. CKAD/Core Concepts

Practice Test - Service

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

kubectl get services

 

ㅁ What is the type of the default kubernetes service?

kubectl get services --all-namespaces

 

ㅁ What is the targetPort configured on the kubernetes service?

ㅁ How many labels are configured on the kubernetes service

ㅁ How many Endpoints are attached on the kubernetes service?

kubectl describe service kubernetes

Name:              kubernetes
Namespace:         default
Labels:            component=apiserver
                   provider=kubernetes
Annotations:       <none>
Selector:          <none>
Type:              ClusterIP
IP Families:       <none>
IP:                10.96.0.1
IPs:               10.96.0.1
Port:              https  443/TCP
TargetPort:        6443/TCP
Endpoints:         10.108.52.6:6443
Session Affinity:  None
Events:            <none>
kubectl get services kubernetes

NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   8m55s

 

ㅁ How many Deployments exist on the system now?

in the current(Default) namespace

kubectl get deployment

 

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

kubectl get deployment

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
simple-webapp-deployment   4/4     4            4           53s


kubectl describe deployment simple-webapp-deployment

Name:                   simple-webapp-deployment
Namespace:              default
CreationTimestamp:      Wed, 24 Mar 2021 13:49:23 +0000
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               name=simple-webapp
Replicas:               4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  name=simple-webapp
  Containers:
   simple-webapp:
    Image:        kodekloud/simple-webapp:red
    Port:         8080/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   simple-webapp-deployment-b56f88b77 (4/4 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  89s   deployment-controller  Scaled up replica set simple-webapp-deployment-b56f88b77 to 4

 

ㅁ Are you able to access the Web UI? Try to access the Web Application UI using the tab simple-webapp-ui above the terminal

No

 

ㅁ Create a new service to access the web applicastion using the service-definition-1.yaml file

 

Name: webapp-service

Type: NodePort

targetPort: 8080

port: 8080

nodePort: 30080

selector: simple-webapp

kubectl expose deployment simple-webapp-deployment --name=webapp-service --target-port=8080 --type=NodePort --port=8080 --dry-run=client -o yaml > svc.yaml
vi svc.yaml
---
apiVersion: v1
kind: Service
metadata:
  name: webapp-service
spec:
  type: NodePort
  ports:
    - targetPort: 8080
      port: 8080
      nodePort: 30080
  selector:
    name: simple-webapp
kubectl apply -f svc.yaml

'CKA &. CKAD > Core Concepts' 카테고리의 다른 글

CKA Tip 2: Imperative Command with kubectl  (0) 2021.03.25
Imperative vs Declarative  (0) 2021.03.24
Service  (0) 2021.03.24
Namespaces & Practic Test  (0) 2021.03.24
Practice Test - Deployment  (0) 2021.03.23