kubernetes ingress controller

./traefik -c traefik.sample.toml

traefik.sample.toml

debug = true
[kubernetes]
endpoint = "http://127.0.0.1:8080"

ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
spec:
  rules:
  - host: foo.bar1.com
    http:
      paths:
      - backend:
          serviceName: nginxsvc1
          servicePort: 8071
  - host: foo.bar2.com
    http:
      paths:
      - backend:
          serviceName: nginxsvc2
          servicePort: 8072

rc-nginx.yaml

apiVersion: v1
kind: ReplicationController
metadata:
  name: rc-nginx
spec:
  replicas: 1
  selector:
    app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

rc-nginx2.yaml

apiVersion: v1
kind: ReplicationController
metadata:
  name: rc-nginx2
spec:
  replicas: 1
  selector:
    app: nginx2
  template:
    metadata:
      labels:
        app: nginx2
    spec:
      containers:
      - name: nginx2
        image: nginx:1.7.9
        ports:
        - containerPort: 80

svc-nginx.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginxsvc
  labels:
    app: nginx
spec:
  type: LoadBalancer
  externalIPs:
    - X.X.X.X
    - X.X.X.X
  ports:
    - protocol: TCP
      port: 8071
      targetPort: 80
  selector:
    app: nginx

svc-nginx2.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginxsvc2
  labels:
    app: nginx2
spec:
  type: LoadBalancer
  externalIPs:
    - X.X.X.X
    - X.X.X.X
  ports:
    - protocol: TCP
      port: 8072
      targetPort: 80
  selector:
    app: nginx2

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>