Skip to content
Snippets Groups Projects
Commit 2808ae1b authored by schnarkus's avatar schnarkus
Browse files

add kubernetes config

parent af16860a
No related branches found
No related tags found
1 merge request!4build new image with ubuntu
Pipeline #65809 failed
.local
artifact.bin
.terraform
*terraform.*
*terraform*
.ssh
kubectl*
#kubectl config current-context
#kubectl api-resources
#kubectl get pods
#init
gcloud container clusters create devops24-cluster \
--zone=europe-west3-a \
--machine-type=e2-medium \
--num-nodes=3 \
--enable-autoscaling \
--min-nodes=3 \
--max-nodes=10
gcloud compute firewall-rules create allow-http-https \
--allow tcp:80,tcp:443 \
--description "Allow HTTP and HTTPS traffic" \
--direction INGRESS
#debug
gcloud container clusters describe devops24-cluster --zone=europe-west3-a
#deploy
kubectl apply -f namespace.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
#size up
gcloud container clusters resize devops24-cluster --num-nodes=5 --zone=europe-west3-a
#debug
kubectl get pods --output wide
kubectl get services --output wide
kubectl get ingress --output wide
#hop in
gcloud compute ssh --zone "europe-west3-a" "gke-devops24-cluster-default-pool-9b4d4dcd-55mt" --project "bht-devops24-ss"
gcloud compute ssh --zone "europe-west3-a" "gke-devops24-cluster-default-pool-9b4d4dcd-n2rb" --project "bht-devops24-ss"
gcloud compute ssh --zone "europe-west3-a" "gke-devops24-cluster-default-pool-9b4d4dcd-phf0" --project "bht-devops24-ss"
#replace
kubectl delete pod [POD_NAME]
kubectl get pods --watch
#delete
gcloud container clusters delete devops24-cluster --zone=europe-west3-a
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: devops24-webservice-deployment
namespace: devops24-namespace
spec:
replicas: 3
selector:
matchLabels:
app: devops24-webservice
template:
metadata:
labels:
app: devops24-webservice
spec:
securityContext:
runAsNonRoot: true
containers:
- name: devops24-webservice-container
image: registry.bht-berlin.de:443/masi9606/webservice:0.0.28
env:
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "8080"
ports:
- name: http
containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"
securityContext:
allowPrivilegeEscalation: false
runAsUser: 65534
livenessProbe:
tcpSocket:
port: http
readinessProbe:
httpGet:
path: /health
port: http
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: devops24-webservice-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-test
rules:
- host: devops24-webservice.35.246.253.128.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: devops24-webservice-service
port:
number: 80
apiVersion: v1
kind: Namespace
metadata:
name: devops24-namespace
apiVersion: v1
kind: Service
metadata:
name: devops24-webservice-service
namespace: devops24-namespace
spec:
selector:
app: devops24-webservice
ports:
- protocol: TCP
name: http
port: 80
targetPort: 8080
type: ClusterIP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment