I am new to Kubernetes. I have setup kubernetes with 1 master and 3 slave nodes. I have created mysql and nginx pods and it is running on different nodes successfully. Now I want to deploy my application. It has nginx,php-fpm, PHPmodule and MySQL combination. How can I achieve this in Kubernetes?
Here is what I have tried for php-fpm,
cat php-fpm.yaml :
apiVersion: v1
kind: Pod
metadata:
name: php-fpm
labels:
name: php-fpm
spec:
containers:
- resources:
limits :
cpu: 0.5
image: php-fpm
name: php-fpm
env:
- name: PHPFPM_SERVICE
# change this
ports:
- containerPort: 9000
name: php-fpm
cat php-fpm-service.yaml :
apiVersion: v1
kind: Service
metadata:
labels:
name: php-fpm
name: php-fpm
spec:
externalIPs:
- 10.128.0.3
ports:
# the port that this service should serve on
- port: 9000
# label keys and values that must match in order to receive traffic for this service
selector:
name: php-fpm
But php-fpm Pod is not running; the output is below.
NAME READY STATUS RESTARTS AGE
mysql 1/1 Running 0 1d
mysql1 1/1 Running 0 18h
nginx 1/1 Running 0 18h
php-fpm 0/1 ErrImagePull 0 1m
How can I get it running?
Your Pod fails to start because it can't find the image you specified on docker hub (ErrImagePull
).
Change php-fpm.yaml
like this:
...
image: php:fpm
...
See the full list of official php image tags.
To get a better overall idea I suggest read the tutorial on running WordPress on kubernetes (using mysql) before you try to roll your own solution.