From 13193d699eb6bf2f3fc8053ac6ded34009d0d947 Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Fri, 6 Aug 2021 21:44:19 -0400 Subject: [PATCH] test de ingressroute --- kustomize/depl.yml | 15 ++++++++++- kustomize/ingress.yml | 48 +++++++++++++++++----------------- kustomize/ingressroute.yml | 50 ++++++++++++++++++++++++++++++++++++ kustomize/kustomization.yaml | 2 +- kustomize/svc.yml | 4 +-- 5 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 kustomize/ingressroute.yml diff --git a/kustomize/depl.yml b/kustomize/depl.yml index 2d20d06..d19cd1d 100644 --- a/kustomize/depl.yml +++ b/kustomize/depl.yml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: "ip-deployment" + name: "ip" labels: app: "front" spec: @@ -16,6 +16,19 @@ spec: containers: - name: "front-apache" image: "jcabillot/ip" + ports: + - name: "http" + containerPort: 8080 + protocol: "TCP" + livenessProbe: + httpGet: + path: "/" + port: "http" + readinessProbe: + httpGet: + path: "/" + port: "http" + replicas: 1 selector: matchLabels: diff --git a/kustomize/ingress.yml b/kustomize/ingress.yml index 1bccd03..52abceb 100644 --- a/kustomize/ingress.yml +++ b/kustomize/ingress.yml @@ -1,25 +1,25 @@ --- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: "ip-deployment" - annotations: - kubernetes.io/ingress.class: "traefik" - traefik.ingress.kubernetes.io/router.entrypoints: "web,websecure" - cert-manager.io/cluster-issuer: "letsencrypt-prod" -spec: - tls: - - hosts: - - "ip.opti.cabillot.eu" - secretName: "ipcabilloteu-tls" - rules: - - host: "ip.opti.cabillot.eu" - http: - paths: - - path: "/" - pathType: "Prefix" - backend: - service: - name: "ip-deployment" - port: - name: "http" +#apiVersion: networking.k8s.io/v1 +#kind: Ingress +#metadata: +# name: "ip" +# annotations: +# kubernetes.io/ingress.class: "traefik" +# traefik.ingress.kubernetes.io/router.entrypoints: "web,websecure" +# cert-manager.io/cluster-issuer: "letsencrypt-prod" +#spec: +# tls: +# - hosts: +# - "ip.opti.cabillot.eu" +# secretName: "ipcabilloteu-tls" +# rules: +# - host: "ip.opti.cabillot.eu" +# http: +# paths: +# - path: "/" +# pathType: "Prefix" +# backend: +# service: +# name: "ip" +# port: +# name: "http" diff --git a/kustomize/ingressroute.yml b/kustomize/ingressroute.yml new file mode 100644 index 0000000..3551f45 --- /dev/null +++ b/kustomize/ingressroute.yml @@ -0,0 +1,50 @@ +--- +# TODO: Named port for service +# but currently unsupported on my k3s cluster https://github.com/traefik/traefik/pull/7668 +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: "ip-websecure" +spec: + entryPoints: + - "websecure" + routes: + - kind: Rule + match: Host(`ip.opti.cabillot.eu`) + middlewares: [] + priority: 10 + services: + - kind: Service + name: "ip" + port: 80 + tls: + secretName: "ipcabilloteu-tls" +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: "ip-web" +spec: + entryPoints: + - "web" + routes: + - match: Host(`ip.opti.cabillot.eu`) + kind: Rule + priority: 10 + services: + # in this IngressRoute the service will be never called + # because of the redirect middleware BUT DO NOT REMOVE ! + - kind: Service + name: "ip" + port: 80 + middlewares: + - name: "httpsredirect" +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: "httpsredirect" +spec: + redirectScheme: + scheme: https + permanent: true diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml index f2c6853..f2d2b82 100644 --- a/kustomize/kustomization.yaml +++ b/kustomize/kustomization.yaml @@ -1,7 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization - resources: - depl.yml - ingress.yml +- ingressroute.yml - svc.yml diff --git a/kustomize/svc.yml b/kustomize/svc.yml index bf4e346..3d59aea 100644 --- a/kustomize/svc.yml +++ b/kustomize/svc.yml @@ -1,13 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: 'ip-deployment' + name: 'ip' spec: type: "ClusterIP" ports: - name: "http" port: 80 protocol: "TCP" - targetPort: 8080 + targetPort: "http" selector: app: "front"