Browse Source

Un ejemplo de ingress funcionando

main
Celestino Rey 2 years ago
parent
commit
9d55aad391
15 changed files with 328 additions and 5 deletions
  1. +33
    -0
      EjemploIngress/app-hola-dos.yaml
  2. +33
    -0
      EjemploIngress/app-hola-uno.yaml
  3. +4
    -0
      EjemploIngress/creaTodo.sh
  4. +61
    -0
      EjemploIngress/dos-deployment.yaml
  5. +1
    -0
      EjemploIngress/entra1.sh
  6. +1
    -0
      EjemploIngress/entra2.sh
  7. +36
    -0
      EjemploIngress/ingress.yaml
  8. +4
    -0
      EjemploIngress/kustomization.yaml
  9. +3
    -0
      EjemploIngress/paraTodo.sh
  10. +11
    -0
      EjemploIngress/pv-local-dos.yaml
  11. +11
    -0
      EjemploIngress/pv-local-uno.yaml
  12. +61
    -0
      EjemploIngress/uno-deployment.yaml
  13. +4
    -2
      Nginx/ingress.yaml
  14. +1
    -3
      Nginx/miweb-deployment.yaml
  15. +64
    -0
      Nginx/miweb-deployment.yaml.antesDeIngress

+ 33
- 0
EjemploIngress/app-hola-dos.yaml View File

@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-helloworld-two
spec:
replicas: 1
selector:
matchLabels:
app: app-helloworld-two
template:
metadata:
labels:
app: app-helloworld-two
spec:
containers:
- name: app-helloworld-two
image: nginx
ports:
- containerPort: 80
env:
- name: TITLE
value: "Welcome to Azure Kubernetes Service (AKS)"
---
apiVersion: v1
kind: Service
metadata:
name: app-helloworld-two
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: app-helloworld-two

+ 33
- 0
EjemploIngress/app-hola-uno.yaml View File

@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-helloworld-one
spec:
replicas: 1
selector:
matchLabels:
app: app-helloworld-one
template:
metadata:
labels:
app: app-helloworld-one
spec:
containers:
- name: app-helloworld-one
image: nginx
ports:
- containerPort: 80
env:
- name: TITLE
value: "Welcome to Azure Kubernetes Service (AKS)"
---
apiVersion: v1
kind: Service
metadata:
name: app-helloworld-one
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: app-helloworld-one

+ 4
- 0
EjemploIngress/creaTodo.sh View File

@ -0,0 +1,4 @@
kubectl create -f pv-local-dos.yaml
kubectl create -f pv-local-uno.yaml
kubectl create -k ./
#watch kubectl get all

+ 61
- 0
EjemploIngress/dos-deployment.yaml View File

@ -0,0 +1,61 @@
apiVersion: v1
kind: Service
metadata:
name: hello-dos
spec:
type: ClusterIP
ports:
- name: http
port: 80
selector:
app: hello-dos
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hello-dos-pv-claim
labels:
app: hello-dos
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-dos
labels:
app: hello-dos
spec:
selector:
matchLabels:
app: hello-dos
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: hello-dos
tier: frontend
spec:
containers:
- name: hello-dos
#image: linuxserver/nginx
image: docker-registry:32000/minginx:2.0
#image: httpd
ports:
- containerPort: 80
volumeMounts:
- name: hello-dos-folder
mountPath: /usr/share/nginx/html
imagePullSecrets:
- name: reg-cred-secret
volumes:
- name: hello-dos-folder
persistentVolumeClaim:
claimName: hello-dos-pv-claim

+ 1
- 0
EjemploIngress/entra1.sh View File

@ -0,0 +1 @@
kubectl exec -ti deployment.apps/app-helloworld-one -- /bin/bash

+ 1
- 0
EjemploIngress/entra2.sh View File

@ -0,0 +1 @@
kubectl exec -ti deployment.apps/app-helloworld-two -- /bin/bash

+ 36
- 0
EjemploIngress/ingress.yaml View File

@ -0,0 +1,36 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- host: k8s-server
http:
paths:
- path: /hello-world-one(/|$)(.*)
pathType: Prefix
backend:
service:
name: hello-uno
port:
number: 80
- path: /hello-world-two(/|$)(.*)
pathType: Prefix
backend:
service:
name: hello-dos
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: hello-uno
port:
number: 80

+ 4
- 0
EjemploIngress/kustomization.yaml View File

@ -0,0 +1,4 @@
resources:
- uno-deployment.yaml
- dos-deployment.yaml
- ingress.yaml

+ 3
- 0
EjemploIngress/paraTodo.sh View File

@ -0,0 +1,3 @@
kubectl delete -k ./
kubectl delete -f pv-local-uno.yaml
kubectl delete -f pv-local-dos.yaml

+ 11
- 0
EjemploIngress/pv-local-dos.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: hello-dos-folder
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/cluster/hello/dos"

+ 11
- 0
EjemploIngress/pv-local-uno.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: hello-uno-folder
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/cluster/hello/uno"

+ 61
- 0
EjemploIngress/uno-deployment.yaml View File

@ -0,0 +1,61 @@
apiVersion: v1
kind: Service
metadata:
name: hello-uno
spec:
type: ClusterIP
ports:
- name: http
port: 80
selector:
app: hello-uno
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hello-uno-pv-claim
labels:
app: hello-uno
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-uno
labels:
app: hello-uno
spec:
selector:
matchLabels:
app: hello-uno
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: hello-uno
tier: frontend
spec:
containers:
- name: hello-uno
#image: linuxserver/nginx
image: docker-registry:32000/minginx:2.0
#image: httpd
ports:
- containerPort: 80
volumeMounts:
- name: hello-uno-folder
mountPath: /usr/share/nginx/html
imagePullSecrets:
- name: reg-cred-secret
volumes:
- name: hello-uno-folder
persistentVolumeClaim:
claimName: hello-uno-pv-claim

+ 4
- 2
Nginx/ingress.yaml View File

@ -3,12 +3,14 @@ kind: Ingress
metadata:
name: reymota-ingress
annotations:
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- http:
paths:
- path: /nginx
- path: /(.*)
pathType: Prefix
backend:
service:


+ 1
- 3
Nginx/miweb-deployment.yaml View File

@ -55,9 +55,7 @@ spec:
name: "nginx-http"
volumeMounts:
- name: nginx-www-folder
#mountPath: /config/www
mountPath: /config
#mountPath: /usr/local/apache2/htdocs
mountPath: /usr/share/nginx/html
imagePullSecrets:
- name: reg-cred-secret
volumes:


+ 64
- 0
Nginx/miweb-deployment.yaml.antesDeIngress View File

@ -0,0 +1,64 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-example
spec:
type: NodePort
ports:
- name: http
port: 80
nodePort: 30080
targetPort: nginx-http
selector:
app: nginx
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-pv-claim
labels:
app: nginx
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-example
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: nginx
tier: frontend
spec:
containers:
- name: nginx
#image: linuxserver/nginx
image: docker-registry:32000/minginx:2.0
#image: httpd
ports:
- containerPort: 80
name: "nginx-http"
volumeMounts:
- name: nginx-www-folder
mountPath: /usr/share/nginx/html
imagePullSecrets:
- name: reg-cred-secret
volumes:
- name: nginx-www-folder
persistentVolumeClaim:
claimName: nginx-pv-claim

Loading…
Cancel
Save