part2 is done (with volumes and a different index for each service)

This commit is contained in:
starnakin 2025-02-27 07:47:22 -05:00
parent cc358ecf93
commit 8671147c79
6 changed files with 160 additions and 5 deletions

View File

@ -17,11 +17,22 @@ spec:
containers:
- name: app1
image: nginx:1.14.2
volumeMounts:
- name: indexes
mountPath: /usr/share/nginx/html/index.html
subPath: app1
volumes:
- name: indexes
configMap:
name: indexes
items:
- key: app1
path: app1
---
apiVersion: v1
kind: Service
metadata:
name: app1
name: app1-service
spec:
type: NodePort
selector:
@ -29,4 +40,3 @@ spec:
ports:
- port: 80
targetPort: 80
nodePort: 30080

42
p2/confs/app2.yaml Normal file
View File

@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app2-deployment
labels:
app: app2
spec:
replicas: 3
selector:
matchLabels:
app: app2
template:
metadata:
labels:
app: app2
spec:
containers:
- name: app2
image: nginx:1.14.2
volumeMounts:
- name: indexes
mountPath: /usr/share/nginx/html/index.html
subPath: app2
volumes:
- name: indexes
configMap:
name: indexes
items:
- key: app2
path: app2
---
apiVersion: v1
kind: Service
metadata:
name: app2-service
spec:
type: NodePort
selector:
app: app2
ports:
- port: 80
targetPort: 80

42
p2/confs/app3.yaml Normal file
View File

@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app3-deployment
labels:
app: app3
spec:
replicas: 1
selector:
matchLabels:
app: app3
template:
metadata:
labels:
app: app3
spec:
containers:
- name: app3
image: nginx:1.14.2
volumeMounts:
- name: indexes
mountPath: /usr/share/nginx/html/index.html
subPath: app3
volumes:
- name: indexes
configMap:
name: indexes
items:
- key: app3
path: app3
---
apiVersion: v1
kind: Service
metadata:
name: app3-service
spec:
type: NodePort
selector:
app: app3
ports:
- port: 80
targetPort: 80

11
p2/confs/indexes.yaml Normal file
View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: indexes
data:
app1: |
<h1>App1</h1>
app2: |
<h1>App2</h1>
app3: |
<h1>App3</h1>

38
p2/confs/ingress.yaml Normal file
View File

@ -0,0 +1,38 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx # Ensure this matches your Ingress class
rules:
- host: "app1.com"
http:
paths: # Ensure correct indentation under "http"
- path: "/"
pathType: Prefix
backend:
service:
name: app1-service
port:
number: 80
- host: "app2.com"
http:
paths: # Ensure correct indentation under "http"
- path: "/"
pathType: Prefix
backend:
service:
name: app2-service
port:
number: 80
- http:
paths: # Ensure correct indentation under "http"
- path: "/"
pathType: Prefix
backend:
service:
name: app3-service
port:
number: 80

View File

@ -1,7 +1,8 @@
#!/bin/sh
# this is some weird stuff nws
alias jj='sudo rm -rf /tmp/juju*'
echo "alias jj='sudo rm -rf /tmp/juju*'" >> /home/vagrant/.bashrc
source /home/vagrant/.bashrc
# install docker
sudo apt-get update
@ -26,5 +27,16 @@ curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikub
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
sudo minikube start --driver=docker --force
jj
sudo minikube kubectl -- apply -f /vagrant/confs/app1.yaml
sudo minikube addons enable ingress
sudo minikube kubectl -- apply -f /vagrant/confs/indexes.yaml
sudo minikube kubectl -- apply -f /vagrant/confs/app1.yaml
sudo minikube kubectl -- apply -f /vagrant/confs/app2.yaml
sudo minikube kubectl -- apply -f /vagrant/confs/app3.yaml
until sudo minikube kubectl -- apply -f /vagrant/confs/ingress.yaml
do
echo ingress failed try again
done