<1> 컨테이너 이미지 생성 <2> pod 생성 <3> cpu 사용룰 증가하면 pod 증가 시키기 <4> 부하 증가해서 확인하기 <1> 컨테이너 이미지 생성 vi index.php -------------------------------------------------------- # docker build -t hpa-example . # docker images # docker login -u .kr.ncr.ntruss.com Password : Login Succeeded # docker image tag hpa_example /hpa_example:1.0 # docker push /hpa_example:1.0 vi Dockerfile ------------------------------------------------------------------------------------------------------------------------ FROM php:5-apache COPY index.php /var/www/html/index.php RUN chmod a+rx index.php <2> pod 생성 1 vi hpa-php.yaml apiVersion: apps/v1 kind: Deployment metadata: name: php-apache spec: selector: matchLabels: run: php-apache replicas: 1 template: metadata: labels: run: php-apache spec: containers: - name: php-apache image: /hpa_example:1.0 imagePullPolicy: Always ports: - containerPort: 80 resources: limits: cpu: 500m requests: cpu: 200m imagePullSecrets: - name: regcred --- apiVersion: v1 kind: Service metadata: name: php-apache labels: run: php-apache spec: ports: - port: 80 selector: run: php-apache kubectl create -f hpa-php.yaml kubectl get deployments kubectl get pods kubectl get service <3> cpu 사용룰 증가하면 pod 증가 시키기 # kubectl autoscale deployment php-apache --cpu-percent=30 --min=1 --max=10 # kubectl get hpa <4> 부하 증가해서 확인하기 kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://php-apache; done" 감사합니다.