728x90
반응형

Deployment

  • 파드들을 관리함을 의미
  • rolling update, rollback, scaling 과 같은 기능을 제공
  • web server, APIs, microservices에 적합하게 만듬
apiVersion: apps/v1  
kind: Deployment                        // Deployment 정의 
metadata:  
    name: webapp-deployment  
spec:  
    replicas: 3                         // 3개의 레플리카(인스턴스) - 아래 파드들
    selector:  
        matchLabels:  
            app: my-webapp  
    template:  
        metadata:  
            labels:  
                app: my-webapp  
        spec:  
            containers:  
            - name: webapp  
              image: nginx:latest  
              ports:  
                - containerPort: 80  
              envFrom:  
                - configMapRef:  
                    name: webapp-config  
            - name: database  
              image: mongo:latest  
              env:  
                - name: MONGO_INITDB_ROOT_USERNAME  
                  valueFrom:   
                    secretKeyRef:  
                        name: db-credentials  
                        key: username  
                - name: MONGO_INITDB_ROOT_PASSWORD  
                  valueFrom:  
                    secretKeyRef:  
                        name: db-credentials  
                        key: password  
              volumeMounts:  
                - name: db-data  
                  mountPath: /data/db  
    volumes:  
        - name: db-data  
          persistentVolumeClaim:  
          claimName: database-pvc  

---  

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

---  

apiVersion: v1  
kind: ConfigMap  
metadata:  
    name: webapp-config  
data:  
    WEBAPP_ENV: "production"  
    DATABASE_URL: "mongodb://database-service:27017/mydb"  

---  

apiVersion: v1  
kind: Secret  
metadata:  
    name: db-credentials  
type: Opaque  
data:  
    username: <base64-encoded-username>  
    password: <base64-encoded-password>  

---  

apiVersion: v1  
kind: PersistentVolumeClaim  
metadata:  
    name: database-pvc  
spec:  
    accessModes:  
        - ReadWriteOnce  
    resources:  
        requests:  
            storage: 1Gi
728x90
반응형

+ Recent posts