Microsevices Architectue

2025. 1. 7. 18:17쿠버네티스/Kubernetes for the Absolute Beginners

728x90
반응형

redis yaml

##dployment
apiVersion: apps:/v1
kind: Deployment
metadata:
  name: redis-deploy
  labels:
    app: redis-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      name: redis-app
      labels:
        name: redis-pod
        app: demo-voting-app
    sepc:
      containers:
        - name: redis
          image: redis
          ports:
            - containerPort: 6379



#service
apiVersion: v1
kind: service
metadata:
  name: redis-service
  labels:
    name: redis-service
    app: demo-voting-app
spec:
  ports:
    - port: 6379
      targetPort: 6379
  selector:
    name: redis-pod
    app: demo-voting-app

postgres yaml

##dployment
apiVersion: apps:/v1
kind: Deployment
metadata:
  name: postgres-deploy
  labels:
    app: postgres-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      name: postgres-app
      labels:
        name: postgres-pod
        app: demo-voting-app
    sepc:
      containers:
        - name: postgres
          image: postgres
          ports:
            - containerPort: 5432
          env:
            - name: POSTGERS_USER
              value: "postgres"
            - name: POSTGRES_PASSWORD
              value: "postgres"
            
#service
apiVersion: v1
kind: service
metadata:
  name: postgres-service
  labels:
    name: postgres-service
    app: demo-voting-app
spec:
  ports:
    - port: 5432
      targetPort: 5432
  selector:
    name: postgres-pod
    app: demo-voting-app

worker yaml

##dployment
apiVersion: apps:/v1
kind: Deployment
metadata:
  name: worker-deploy
  labels:
    name: worker-deploy
    app: demo-voting-app
spec:
  replicas: 3
  selector:
    matchLabels:
      name: worker-pod
      app: demo-voting-app
  template:
    metadata:
      name: worker-app
      labels:
        name: worker-pod
        app: worker
    sepc:
      containers:
        - name: worker-app
          image: kodekloud/examplevotingapp_worker:v1

voting yaml

##dployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: voting-app-deploy
  labels:
    name: voting-app-deploy
    app: demo-voting-app
spec:
  replicas: 1
  selector:
    matchLabels:
      name: voting-app-pod
      app: demo-voting-app
  template:
    metadata:
      name: voting-app-pod
      labels:
        name: voting-app-pod
        app: demo-voting-app
    spec:
      containers:
      - name: voting-app
        image: kodekloud/examplevotingapp_vote:v1
        ports:
        - containerPort: 80

#service
---
apiVersion: v1
kind: Service
metadata:
  name: voting-service
  labels:
    name: voting-service
    app: demo-voting-app
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    name: voting-app-pod
    app: demo-voting-app

result yaml

##dployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: result-app-deploy
  labels:
    name: result-app-deploy
    app: demo-voting-app
spec:
  replicas: 1
  selector:
    matchLabels:
      name: result-app-pod
      app: demo-voting-app
  template:
    metadata:
      name: result-app-pod
      labels:
        name: result-app-pod
        app: demo-voting-app
    spec:
      containers:
      - name: result-app
        image: kodekloud/examplevotingapp_result:v1
        ports:
        - containerPort: 80
            
#service
---
apiVersion: v1
kind: Service
metadata:
  name: result-service
  labels:
    name: result-service
    app: demo-voting-app
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    name: result-app-pod
    app: demo-voting-app

 


AKS

  • 외부 IP를 얻기 위해 loadbalce 타입으로 서비스 객체 생성

kubectl get all
NAME                                     READY   STATUS    RESTARTS      AGE
pod/postgres-deploy-776f4bdfcb-p2nt7     1/1     Running   0             17m
pod/redis-deploy-54b67b7b4-4p5vr         1/1     Running   0             18m
pod/result-app-deploy-7cc95854b6-kgtwv   1/1     Running   0             18m
pod/voting-app-deploy-96f58547f-lk5hf    1/1     Running   0             20m
pod/worker-app-deploy-54575bd48c-kpp4h   1/1     Running   2 (17m ago)   18m

NAME                     TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)        AGE
deployment.apps/result-app-deploy   1/1     1            1           18m
deployment.apps/voting-app-deploy   1/1     1            1           20m
deployment.apps/worker-app-deploy   1/1     1            1           18m

NAME                                           DESIRED   CURRENT   READY   AGE
replicaset.apps/postgres-deploy-776f4bdfcb     1         1         1       17m
replicaset.apps/redis-deploy-54b67b7b4         1         1         1       18m
replicaset.apps/result-app-deploy-7cc95854b6   1         1         1       18m
replicaset.apps/voting-app-deploy-96f58547f    1         1         1       20m
replicaset.apps/worker-app-deploy-54575bd48c   1         1         1       18m

C:\Users\skyhy\demotest>kubectl get all
NAME                                     READY   STATUS    RESTARTS      AGE
pod/postgres-deploy-776f4bdfcb-p2nt7     1/1     Running   0             20m
pod/redis-deploy-54b67b7b4-4p5vr         1/1     Running   0             20m
pod/result-app-deploy-7cc95854b6-kgtwv   1/1     Running   0             20m
pod/voting-app-deploy-96f58547f-lk5hf    1/1     Running   0             22m
pod/worker-app-deploy-54575bd48c-kpp4h   1/1     Running   2 (20m ago)   20m

NAME                     TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)        AGE
service/db               ClusterIP      10.0.245.131   <none>         5432/TCP       20m
service/kubernetes       ClusterIP      10.0.0.1       <none>         443/TCP        10d
service/redis            ClusterIP      10.0.164.213   <none>         6379/TCP       20m
service/result-service   LoadBalancer   10.0.167.33    20.249.65.39   80:30005/TCP   20m
service/voting-service   LoadBalancer   10.0.199.80    20.249.65.71   80:30004/TCP   21m

NAME                                READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/postgres-deploy     1/1     1            1           20m
deployment.apps/redis-deploy        1/1     1            1           20m
deployment.apps/result-app-deploy   1/1     1            1           20m
deployment.apps/voting-app-deploy   1/1     1            1           22m
deployment.apps/worker-app-deploy   1/1     1            1           20m

NAME                                           DESIRED   CURRENT   READY   AGE
replicaset.apps/postgres-deploy-776f4bdfcb     1         1         1       20m
replicaset.apps/redis-deploy-54b67b7b4         1         1         1       20m
replicaset.apps/result-app-deploy-7cc95854b6   1         1         1       20m
replicaset.apps/voting-app-deploy-96f58547f    1         1         1       22m
replicaset.apps/worker-app-deploy-54575bd48c   1         1         1       20m

반응형

'쿠버네티스 > Kubernetes for the Absolute Beginners' 카테고리의 다른 글

Services  (0) 2025.01.07
Deployments  (0) 2025.01.07
Replication Controllers and ReplicaSets  (0) 2025.01.07
PODs with YAML  (0) 2025.01.07