본문 바로가기

CKA &. CKAD/Scheduling

Labels and Selectors

Pod-definition.yaml

apiVersion: v1
kind: Pod
metatdata:
  name: simple-webapp
  labels;
    app: App1
    function: Front-end

spec:
  containers:
  - name: simple-webapp
    image: simple-webapp
    ports:
      - containerPort: 8080

Select

kubectl get pods --selector app=App1

 

Replicaset-definition.yaml

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: simple-webapp
  labels:
    app: App1
    function: Front-end  
  annotations:
      buildversion: 1.34
spec:
  replicas: 3
  selector:
    matchLabels:
      app: App1
  template:
    metadata:
      labels:
        app: App1
        function: Front-end
    spec:
      containers:
      - name: simple-webapp
        image: simple-webapp

Service-definition.yaml

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: App1
  ports:
  - protocol: 
    port: 80
    targetPort: 9376

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

Resource Limits  (0) 2021.03.26
Practice Test - Node Selectors/Affinity  (0) 2021.03.26
Practice Test - Taints and Tolerations  (0) 2021.03.26
Practice Test - Labels and Selectors  (0) 2021.03.25
Manual Scheduling  (0) 2021.03.25