i'm having an hard time to start learning kubernetes the documentations isn't really simple i want to realize simple trick for the moment i'm familliar with docker and i wan't to learn orchestration with kubernetes . i've realized the following yml file :
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
spec:
selector:
matchLabels:
app: test
replicas: 1 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: test
spec:
containers:
- name: test
image: ubuntu:20.04
command: ["/scripts/ubuntu.sh"]
ports:
- containerPort: 80
- containerPort: 443
volumeMounts:
- name: scripts
mountPath: /scripts
volumes:
- name: scripts
configMap:
name: scripts
defaultMode: 0744
in my sh file i've got the following :
#!/bin/sh
apt install -y apache2 && service apache2 start && tail -f /dev/null
the idea is to launch an ubuntu , install apache2 , start the service , keep container alive with a tail , and being able to go on the mapped 80 port from container to my host .
i think i'm doing something wrong when i launch kubectl apply -f i get :
deployment.apps/test-deployment created
but nothing up on my localhost unfortunatly ...
anyone already had that problem ?
PS: i'm using docker desktop on windows .
Edit :
Now i got my pods running but i cannot access my apache on localhost:80 heres my actual config :
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
labels:
app: apache
spec:
selector:
matchLabels:
app: test
replicas: 1 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: test
spec:
containers:
- name: test
image: ubuntu:20.04
command: ["/bin/sh", "-c", "apt update -y && apt install -y apache2 && service apache2 start && tail -f /dev/null"]
ports:
- name: http
containerPort: 80
env:
- name: DEBIAN_FRONTEND
value: noninteractive
---
apiVersion: v1
kind: Service
metadata:
name: apache-service
spec:
selector:
app: apache
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30001