Lets try to run our docker image with k8s...
Kubernetes should run, monitor, restart and scale our application "service1".
cd ~/service1
vim service1-deployment.yaml
# See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ for example content used here
cd ~/service1
docker build --tag easyk8s-service1 . -f Dockerfile
Sending build context to Docker daemon 6.144kB
Step 1/4 : FROM python:3
---> 659f826fabf4
Step 2/4 : ADD service.py /
---> ccd341c35691
Step 3/4 : COPY www /
---> 605b15b64ab0
Step 4/4 : CMD ["python", "service.py"]
---> Running in a9aaa32e5fdc
Removing intermediate container a9aaa32e5fdc
---> 232da1056511
Successfully built 232da1056511
Successfully tagged easyk8s-service1:latest
Step 1/4 : FROM python:3
---> 659f826fabf4
Step 2/4 : ADD service.py /
---> ccd341c35691
Step 3/4 : COPY www /
---> 605b15b64ab0
Step 4/4 : CMD ["python", "service.py"]
---> Running in a9aaa32e5fdc
Removing intermediate container a9aaa32e5fdc
---> 232da1056511
Successfully built 232da1056511
Successfully tagged easyk8s-service1:latest
vim service1-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: service1-deployment
labels:
app: service1
spec:
replicas: 1
selector:
matchLabels:
app: service1
template:
metadata:
labels:
app: service1
spec:
containers:
- name: service1
image: easyk8s-service1
ports:
- containerPort: 8888
kind: Deployment
metadata:
name: service1-deployment
labels:
app: service1
spec:
replicas: 1
selector:
matchLabels:
app: service1
template:
metadata:
labels:
app: service1
spec:
containers:
- name: service1
image: easyk8s-service1
ports:
- containerPort: 8888
# Lets not import the configuration...
kubectl apply -f service1-deployment.yaml
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
# What is wrong?
kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
What happened? I have no cluster defined. I cannot create a deployment nor do anything until cluster and other things are defined.
Comments
Post a Comment