docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
756 stars 86 forks source link

Soft constraints in Docker Swarm Mode #786

Open marcusreese opened 5 years ago

marcusreese commented 5 years ago

Expected behavior

I would like tilde in constraint to cause Docker Swarm Mode to use the constraint if possible but deploy to another node if the specified node is not available. E.g.,

      placement:
        constraints:
        - node.hostname ==~ jetson-nano

If I am reading it correctly, this was done for Swarm Standalone/Classic in https://github.com/docker/swarm/pull/478 In Kubernetes, I believe this would be done via "preferred" (soft) nodeAffinity and weight: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity

Actual behavior

for ==~

value '~ jetson-nano' is invalid

or for =~

constraint expected one operator from ==, !=

I could not find docs or issues on this for version >= 1.12.

Steps to reproduce the behavior


root@Pi4-4GB-51:~# docker node ls
``` ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION oc..dv * Pi4-4GB-51 Ready Active Leader 19.03.1 ul..r4 jetson-nano Ready Active 18.09.2 ```

root@Pi4-4GB-51:~# cat docker-compose.yml
``` version: "3.7" services: submarineService: image: 192.168.240.51:5000/submarine deploy: placement: constraints: - node.hostname ==~ jetson-nano networks: - overlay networks: overlay: ```

root@Pi4-4GB-51:~# docker stack deploy -c docker-compose.yml submarine-stack
``` Creating service submarine-stack_submarineService failed to create service submarine-stack_submarineService: Error response from daemon: rpc error: code = Unknown desc = value '~ jetson-nano' is invalid ``` **Output of `docker version`:** ``` Client: Docker Engine - Community Version: 19.03.1 API version: 1.40 Go version: go1.12.5 Git commit: 74b1e89 Built: Thu Jul 25 21:33:17 2019 OS/Arch: linux/arm Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.1 API version: 1.40 (minimum version 1.12) Go version: go1.12.5 Git commit: 74b1e89 Built: Thu Jul 25 21:27:09 2019 OS/Arch: linux/arm Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683 ``` **Output of `docker info`:** ``` Client: Debug Mode: false Server: Containers: 1 Running: 1 Paused: 0 Stopped: 0 Images: 21 Server Version: 19.03.1 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: active NodeID: oce4gvfxqz7ixv26rz97kr4wv Is Manager: true ClusterID: r1ruunzjj3ciumji4027b29pn Managers: 1 Nodes: 6 Default Address Pool: 10.0.0.0/8 SubnetSize: 24 Data Path Port: 4789 Orchestration: Task History Retention Limit: 5 Raft: Snapshot Interval: 10000 Number of Old Snapshots to Retain: 0 Heartbeat Tick: 1 Election Tick: 10 Dispatcher: Heartbeat Period: 5 seconds CA Configuration: Expiry Duration: 3 months Force Rotate: 0 Autolock Managers: false Root Rotation In Progress: false Node Address: 192.168.240.51 Manager Addresses: 192.168.240.51:2377 Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 4.19.57-v7l+ Operating System: Raspbian GNU/Linux 10 (buster) OSType: linux Architecture: armv7l CPUs: 4 Total Memory: 3.814GiB Name: Pi4-4GB-51 ID: 5D56:BMFZ:MZY2:654W:4QWJ:TLHL:6VMV:ATAP:EXTP:TBUM:HNVL:YL6T Docker Root Dir: /var/lib/docker Debug Mode: false HTTP Proxy: http://127.0.0.1:5000 HTTPS Proxy: http://127.0.0.1:5000 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.1:5000 192.168.240.51:5000 127.0.0.0/8 Live Restore Enabled: false WARNING: No swap limit support WARNING: No cpu cfs quota support WARNING: No cpu cfs period support ``` **Additional environment details (AWS, VirtualBox, physical, etc.)** physical (manager: Raspberry Pi 4, worker: Jetson Nano)
yuliswe commented 4 years ago

I’m looking for the same feature.

Adam7288 commented 1 year ago

+1