Reputation: 405
I have 3 nodes in Google Cloud Plataform with Kubernetes engine and i have a .gital-ci.yml file that update the pods. All apparently works fine, i just have an index.html to be updated and when i check it in the server, its updated. My problem is that when i try to access the external ip with the port, the index.html is not updated. I read something about cache, and i tried to run the command kubectl rollout restart deploy app, but it didn't work. I don't know if it is useful, but to access the page i needed to release the firewall by using this command: gcloud compute firewall-rules create cd-cd-kube --allow tcp:30005
HTML file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App version 2.1</title>
</head>
<body>
<h1>App 2.1</h1>
</body>
</html>
.gitlab-ci.yml file:
stages:
- build
- deploy_gcp
build_images:
stage: build
image: docker:20.10.16
services:
- docker:20.10.16-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u $REGISTRY_USER -p $REGISTRY_PASS
script:
- docker build -t guirms/app-cicd-dio:1.0 app/.
- docker push guirms/app-cicd-dio:1.0
deploy_gcp:
stage: deploy_gcp
before_script:
- chmod 400 $SSH_KEY
script:
- ssh -o StrictHostKeyChecking=no -i $SSH_KEY gcp@$SSH_SERVER "sudo rm -Rf ./ci-cd-kubernetes/ && sudo git clone https://gitlab.com/guirms/ci-cd-kubernetes.git && cd ci-cd-kubernetes && sudo chmod +x ./script.sh && ./script.sh"
deployment.yml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
labels:
app: app
spec:
replicas: 3
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: guirms/app-cicd-dio:1.0
imagePullPolicy: Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: app-service
spec:
type: NodePort
ports:
- targetPort: 80
port: 80
nodePort: 30005
selector:
app: app
script.sh file:
#!/bin/bash
kubectl apply -f deployment.yml
dockerfile file:
FROM httpd:latest
WORKDIR /usr/local/apache2/htdocs/
COPY index.html /usr/local/apache2/htdocs/
EXPOSE 80
Upvotes: 0
Views: 106
Reputation: 473
docker run --entrypoint=sh -it guirms/app-cicd-dio:1.0
With this command, you will be shared with the container. Then you can cat
index.html to double check that version 1.0
contains the index.html you need.
kubectl rollout
or kubectl delete
and then kubectl apply
. Due to your pullPolicy: Always
, the image must be pulled.Upvotes: 1