3. EKS로 Wordpress 띄우기(2/n)- wordpress 배포

yuran3391·2021년 7월 6일
1

EKS

목록 보기
4/4

Wordpress 상세

  • Deployment : 2개
  • Secret활용
  • SVC : LoadBalancer 타입으로 생성
  • Ingress(선택) : Route53으로 도메인 생성 후 할당
  • PVC : EFS
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  replicas: 2
  selector:
    matchLabels:
      app: wordpress
      tier: frontend
  strategy:
    type: Recreate 
  template:
    metadata: 
      labels: 
        app: wordpress
        tier: frontend
    spec:
      containers:
      - image: wordpress:4.8-apache
        name: wordpress 
        env: 
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql 
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass 
              key: password
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage 
          mountPath: /var/www/html
      volumes: 
      - name: wordpress-persistent-storage 
        persistentVolumeClaim:
          claimName: aws-efs
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
    - port: 80
  selector:
    app: wordpress
    tier: frontend
  type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: aws-efs
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: efs-provisioner
  resources:
    requests:
      storage: 10Mi
---
apiVersion: v1
kind: Secret
metadata:
  name: mysql-pass
type: Opaque
data:
  password: Mkjjlk

풀이


apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  replicas: 2
  selector:
    matchLabels:
      app: wordpress
      tier: frontend
  strategy:
    type: Recreate #배포 전략 필수값은 아님
  template:# 디플로이먼트에 배포해야할 파드의 스펙
    metadata: #데이터에 대한 데이터
      labels: #파드에 붙는 라벨
        app: wordpress
        tier: frontend
    spec:
      containers:
      - image: wordpress:4.8-apache
        name: wordpress #컨테이너의 이름
        env: #어떤 db에 붙을지 정보를 
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql #워드프레스에서 통신할 ip 값 혹은 fqdn, fqdn 사용시 타 서비스 야물파일에 같은 이름 사용해야함.
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:#일반적으로 이렇게 하지말고 secret이나 configmap을 별도로 만들어야함.
              name: mysql-pass 
              key: password
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage #volumes에 쓴 이름 사용
          mountPath: /var/www/html
      volumes: 
      - name: wordpress-persistent-storage #볼륨의 이름 맘대로 해도 됨
        persistentVolumeClaim:
          claimName: aws-efs

#claimName    <string> -required-
    # ClaimName is the name of a PersistentVolumeClaim in the same namespace as
     #the pod using this volume. More info:
     #https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
    - port: 80
  selector:
    app: wordpress
    tier: frontend
  type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: aws-efs
  annotations: volume.beta.kubernetes.io/storage-class: "aws-efs"
  labels:
    app: wordpress
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Mi
      ```
      
      
      
     
트러블 슈팅시

k describe pvc aws-efs

Name: aws-efs
Namespace: default
StorageClass: aws-efs
Status: Pending
Volume:
Labels: app=wordpress
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"labels":{"app":"wordpress"},"name":"aws-efs","namespace":"default"},"sp...
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Events:
Type Reason Age From Message


Warning ProvisioningFailed 15s (x12 over 2m) persistentvolume-controller storageclass.storage.k8s.io "aws-efs" not found

profile
하이

0개의 댓글