Skip to content

Instantly share code, notes, and snippets.

@dsgnr
Created November 25, 2019 14:17
Show Gist options
  • Save dsgnr/19047d69efac6dfbbdc05176cc5cef26 to your computer and use it in GitHub Desktop.
Save dsgnr/19047d69efac6dfbbdc05176cc5cef26 to your computer and use it in GitHub Desktop.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
rules:
- apiGroups:
- ""
resources:
- services
- endpoints
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- ingresses
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
name: traefik-ingress-controller
namespace: default
---
apiVersion: v1
kind: Service
metadata:
name: traefik
spec:
ports:
- protocol: TCP
name: web
port: 8000
- protocol: TCP
name: admin
port: 8080
selector:
app: traefik
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: default
name: traefik-ingress-controller
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
namespace: default
name: traefik
labels:
app: traefik
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
serviceAccountName: traefik-ingress-controller
containers:
- name: traefik
image: traefik:v2.0
args:
- --api
- --accesslog
- --entrypoints.web.Address=:8000
- --providers.kubernetesingress
ports:
- name: web
containerPort: 8000
- name: admin
containerPort: 8080
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: whoami
spec:
replicas: 1
template:
metadata:
labels:
app: whoami
spec:
containers:
- name: whoami
image: containous/whoami
imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: whoami
labels:
app: whoami
spec:
type: ClusterIP
ports:
- port: 80
name: whoami
selector:
app: whoami
---
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: whoami
labels:
app: whoami
annotations:
kubernetes.io/ingress.class: 'traefik'
spec:
rules:
- host: whoami.localhost
http:
paths:
- backend:
serviceName: whoami
servicePort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment