Rancher CLI update loadbalancer

Hi there,

I’m using Rancher over Kubernetes to create our test/dev environment. First of all, it’s a great tool and I’m amazed of how it simplify the management of such environments.

That said, I have an issue (which is probably more a knowledge lack of Rancher). I try to automate the deployment via Jenkins, and as we will have several stacks into our test environment, I want to dynamically update the loadbalancer instances to add routes for new environement from Jenkins with Rancher CLI.

At the moment, I just try to run this command :

rancher --url http://myrancher_server:8080 --access-key <key> --secret-key <secret> --env dev-test stack create kubernetes-ingress-lbs -r loadbalancer-rancher-service.yml

My docker-compose.yml file is like the following :

version: '2'
    image: rancher/load-balancer-service
  - 82: 8086
  - fronted:frontend

My rancher compose file is like this:

version: '2'
    scale: 4
      - source_port: 82
        path: /products
        target_port: 8086
        service: products
      - source_port: 82
        path: /
        target_port: 4201
        service: frontend
    port: 42
    interval: 2000
    unhealthy_threshold: 3
    healthy_threshold: 2
    response_timeout: 2000

Now when I execute this I have the following response :

Bad response statusCode [422]. Status [422 status code 422]. Body: [code=NotUnique, fieldName=name, baseType=error] from [http://myrancher_server:8080/v2-beta/projects/1a21/stacks]

Obviously I can’t edit an existing stack with a service that already exsit. Do you know if it’s best practice do to this like that ? I checked man, and I only see the “create” action on “rancher stack”, so I’m wondering if we can update ?

My rancher server is v1.5.10 and all my rancher agents and Kubernetes drivers are up-to-date.

Thanks a lot for your help fellows :slight_smile:

EDIT : I know it’s a very specific question, and I will also post it on Stackoverflow to increase my chances that someone who know well Kubernetes/Rancher could help me. Sorry for replica.

Ok, just for the information, I found that this is possible via the Rest API of Rancher.

Check the following link : http://docs.rancher.com/rancher/v1.2/en/api/v2-beta/api-resources/service/

I didn’t found that at first 'cause the Googling I’ve done around was all about rancher cli at first. But as it’s still beta, we can’t do the same stuff as via the rest API.

Basically, just send an update resource query :

PUT rancherserver/v2-beta/projects/1a12/services/<id_of_your_service>

	"description": "Loadbalancer for our test env",
	"lbConfig": {
		"portRules": [
				"hostname": "",
				"protocol": "http",
				"source_port": "80",
				"targetPort": "4200",
				"path": "/"
	"name": "kubernetes-ingress-lbs"