Deploy workload and configure L7 ingress (yaml)

In the rancher-ui i am able to deploy a new workload and add a L7 ingress (test.example.com, including certificate). That works like a charm and the needed services (service-discovery) are created automatically.

Is there a way to create the example above with kubectl and yaml-files? As the L7 ingress is rancher-specific i think it won’t be able to configure it through kubernetes-yaml-syntax and needs some special keywords or annotatons?

The deployment of new pods or creating services/ingresses is working but i am not sure how to configure the L7 ingress or what to do that it picks up the change and does its magic.

Alright, i think i just found the solution shortly after i’ve created the thread.
It seems, that the magic happens when using labels and selectors on the ingress and service.

i hope my example will help someone out in the same situation

demo-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    io.bgs.service: demo
  name: demo
spec: 
  replicas: 1
  template:
    metadata:
      labels:
        io.bgs.service: demo
    spec:
      containers: 
      - image: nginxdemos/hello
        name: demo
        ports:
        - containerPort: 80

demo-service.yaml

apiVersion: v1
kind: Service
metadata: 
  labels: 
    io.bgs.service: demo
  name: demo
spec:
  ports:
  - name: "80"
    port: 80
    targetPort: 80
  selector:
    io.bgs.service: demo
status:
  loadBalancer: {}

demo-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo-lb
spec:
  rules:
  - host: demo.example.com
    http:
      paths:
      - backend:
          serviceName: demo
          servicePort: 80
        path: /

You can even use the ingress-manifest to get a certificate from let’s encrypt. The cert-manager will pick up the “tls” keyword and automatically request and install the certificate.

demo-ingress-tls.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo-lb
spec:
  rules:
  - host: demo.example.com
    http:
      paths:
      - backend:
          serviceName: demo
          servicePort: 80
        path: /
  tls: 
  - hosts:
    - demo.example.com
    secretName: demo-example-com-tls 

Just run kubectl with the created manifests.

[me@host~] kubectl create -f demo-deployment.yaml -f demo-service.yaml -f demo-ingress.yaml
deployment.extensions/demo created
service/demo created
ingress.extensions/demo-lb created
1 Like

As you have noted, this is just regular K8s, nothing Rancher specific (nor should there be). You might want to consider consolidating your separate yaml files into one (use the 3 dash separator between each resource type) for easier management and for reasons of cohesion I suppose.