Para la sección Sondas del curso de Kubernetes de Apasoft
87
Directory
.
├── Dockerfile
└── web
├── css
│ └── style.scss
├── index.html
├── js
│ └── script.js
└── sonda.html
Dockerfile
FROM httpd:2.4
COPY ./web /usr/local/apache2/htdocs
LABEL author="pabloqpacin"
LABEL curso="Apasoft: Kubernetes"
EXPOSE 80
Build and push
docker build -t pabloqpacin/sonda-web:v1 .
# docker image ls
docker login
docker push pabloqpacin/sonda-web:v1
# docker tag local-image:tagname new-repo:tagname # ...
Usecases
docker run -d --rm --name sonda1 -p 80:80 pabloqpacin/sonda-web:v1
mkdir ~/k8s/sondas && cd $_
nvim sonda-http.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-d
spec:
selector:
matchLabels:
app: web
replicas: 1
template:
metadata:
labels:
app: web
spec:
containers:
- name: apache
image: pabloqpacin/sonda-web:v1
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /sonda.html
port: 80
initialDelaySeconds: 3
periodSeconds: 3
---
apiVersion: v1
kind: Service
metadata:
name: web-svc
labels:
app: web
spec:
type: NodePort
ports:
- port: 80
nodePort: 30002
protocol: TCP
selector:
app: web
kubectl apply -f sonda-http.yaml
# kubectl get deploy && kubectl get pods && kubectl get rs && kubectl get svc
# curl localhost:30002
kubectl describe pod <pod> | grep 'Liveness'
kubectl exec -it <pod> -- bash
# ls -la htdocs
# rm htdocs/sonda.html
kubectl describe pod <pod> | grep -C5 'probe failed'
# RESTART HAPPENS
Content type
Image
Digest
sha256:fb67770da…
Size
61.5 MB
Last updated
over 2 years ago
docker pull pabloqpacin/sonda-web:v1