Deploy PHP and Nginx app using Kubernetes
apiVersion: apps/v1 kind: Deployment metadata: name: app-deployment labels: app: php-app spec: selector: matchLabels: app: php-app template: metadata: name: app-deployment labels: app: php-app spec: containers: - name: nginx-container image: ...your nginx image ports: - containerPort: 443 - name: php-container image: ..your php image ports: - containerPort: 80
apiVersion: v1 kind: Service metadata: name: nginx-app-service spec: type: NodePort ports: - targetPort: 80 port: 80 nodePort: 30008 selector: app: php-app
- kubectl create -f deployment.yml - kubectl create -f service-nodeport.yml - kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-app-service NodePort 10.152.183.2280:30008/TCP 13m - kubectl get node -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME microk8s-vm Ready none 10d v1.18.2-41+b5cdb79a4060a3 192.168.64.3 Ubuntu 18.04.4 LTS 4.15.0-101-generic containerd://1.2.5
apiVersion: v1 kind: Service metadata: name: nginx-app-service spec: type: LoadBalancer ports: - targetPort: 80 port: 80 selector: app: php-app
- kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-app-service LoadBalancer ............. ........... 80:32280/TCP 4m26s