initial traefik setup

This commit is contained in:
Mans Ziesel 2024-09-22 11:52:27 +02:00
parent 5e218fd023
commit 18e8eaf11f
15 changed files with 235 additions and 32 deletions

View File

@ -0,0 +1,20 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-app-metallb
namespace: argocd
spec:
destination:
name: ''
namespace: default
server: https://kubernetes.default.svc
source:
path: metallb
repoURL: https://git.mziesel.nl/mans/argocd-test
targetRevision: HEAD
sources: []
project: default
syncPolicy:
automated:
prune: true
selfHeal: true

View File

@ -0,0 +1,20 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-app-traefik
namespace: argocd
spec:
destination:
name: ''
namespace: default
server: https://kubernetes.default.svc
source:
path: traefik
repoURL: https://git.mziesel.nl/mans/argocd-test
targetRevision: HEAD
sources: []
project: default
syncPolicy:
automated:
prune: true
selfHeal: true

View File

@ -0,0 +1,20 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-app-whoami
namespace: argocd
spec:
destination:
name: ''
namespace: default
server: https://kubernetes.default.svc
source:
path: whoami
repoURL: https://git.mziesel.nl/mans/argocd-test
targetRevision: HEAD
sources: []
project: default
syncPolicy:
automated:
prune: true
selfHeal: true

View File

@ -1,20 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: guestbook-ui
spec:
replicas: 3
revisionHistoryLimit: 3
selector:
matchLabels:
app: guestbook-ui
template:
metadata:
labels:
app: guestbook-ui
spec:
containers:
- image: gcr.io/heptio-images/ks-guestbook-demo:0.2
name: guestbook-ui
ports:
- containerPort: 80

View File

@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: guestbook-ui
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 31337
selector:
app: guestbook-ui

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: traefik

View File

@ -0,0 +1,57 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: traefik-role
rules:
- apiGroups:
- ""
resources:
- services
- secrets
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- list
- watch
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses
- ingressclasses
verbs:
- get
- list
- watch
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses/status
verbs:
- update
- apiGroups:
- traefik.io
resources:
- middlewares
- middlewaretcps
- ingressroutes
- traefikservices
- ingressroutetcps
- ingressrouteudps
- tlsoptions
- tlsstores
- serverstransports
- serverstransporttcps
verbs:
- get
- list
- watch

View File

@ -0,0 +1,13 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: traefik-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: traefik-role
subjects:
- kind: ServiceAccount
name: traefik-account
namespace: traefik

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: traefik-account

View File

@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: traefik-dashboard-service
namespace: traefik
spec:
type: LoadBalancer
ports:
- port: 8080
targetPort: dashboard
selector:
app: traefik
---
apiVersion: v1
kind: Service
metadata:
name: traefik-web-service
namespace: traefik
spec:
type: LoadBalancer
ports:
- targetPort: web
port: 80
selector:
app: traefik

View File

@ -0,0 +1,29 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik-deployment
labels:
app: traefik
spec:
replicas: 3
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
serviceAccountName: traefik-account
containers:
- name: traefik
image: traefik:v3.1
args:
- --api.insecure
- --providers.kubernetesingress
ports:
- name: web
containerPort: 80
- name: dashboard
containerPort: 8080

View File

@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kube-system
resources:
- ./base/000-namespace.yaml
- ./base/001-role-binding.yaml
- ./base/001-cluster-role.yaml
- ./base/002-service-account.yaml
- ./base/003-traefik.yaml
- ./base/003-traefik-services.yaml

View File

View File

@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami-ingress
namespace: traefik
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: whoami
port:
name: web

View File

@ -24,3 +24,16 @@ spec:
targetPort: 80 targetPort: 80
selector: selector:
app: whoami app: whoami
---
apiVersion: v1
kind: Service
metadata:
name: whoami-traefik
namespace: whoami
spec:
ports:
- name: web
port: 80
targetPort: 80
selector:
app: whoami