A privilege
This page asks for a privilege: a capability the container runtime does not give a container by default. An app may only ask; the operator decides whether its deployment gets it.
First move scores to shc.yaml, which writes the members block the same
way, with service_selectors, live_labels and scale.witness for the
three directives. Once shc.yaml sits beside compose.yaml, shc.yaml is
the app and the compose file is not read. Add a third service, netcheck,
that asks for NET_ADMIN, and a hook that runs before it starts.
service_selectors: kv: role=master:1services:{% members "kv", default=3, max=5 as m %} kv-{{ m.n }}: image: redis:7-alpine command: ["sh", "-c", "if [ {{ m.n }} = 1 ]; then exec redis-server --appendonly yes; else exec redis-server --appendonly yes --replicaof kv-1 6379; fi"] expose: [6379] volumes: - name: data-{{ m.n }} path: /data environment: MEMBER_LOCATION: "{{ m.location }}" live_labels: role: test: ["CMD-SHELL", "redis-cli role | head -n 1"] interval: 5s timeout: 3s{% endmembers %} watcher: image: redis:7-alpine command: ["sh", "-c", "while true; do redis-cli -h kv role | head -n 1; sleep 10; done"] scale: witness: kv netcheck: image: busybox:1.36 command: ["sh", "-c", "ip link set lo mtu 65000 && ip link show lo && sleep infinity"] pre_start: - command: ["sh", "-c", "date -u > /tmp/prepared"] privileges: cap_add: [NET_ADMIN]privileges only asks. NET_ADMIN changes the node’s view of the network
from inside the container, so the deployment must be granted the caps class
before an install or update with it goes through. A grant names the classes
it admits: socket, devices, gpus, privileged, caps, confinement,
host-namespaces and kernel, or true for all of them. Grant it, as an
operator would, and take the grant back after. A grant is read at global
scope only, and with prod selected a set without --scope writes at
tenant scope, which a grant refuses, so the set and the unset name
--scope global.
$ shc update scoresupdating deployment "scores"warning: [X200538SHYTWO] /root/learn/scores has shc.yaml and compose.yaml; shc.yaml is the app and compose.yaml is not readshc: [X403990HSTGNT] deployment prod/prod/scores asks for cap_add NET_ADMIN in service netcheck, a host-reaching feature of class caps; the master tenant's operator grants it with `shc config set privilege.deployment_grants.prod.prod.scores caps` at global scope$ shc config set privilege.deployment_grants.prod.prod.scores caps --scope global...$ shc config get privilege.deployment_grants.prod.prod.scores --db...$ shc update scores...$ shc exec -s scores -S netcheck -- ip link show lo...$ shc config unset privilege.deployment_grants.prod.prod.scores --db --scope global...--db reads and writes the cluster’s own config store, the one every config
command already uses. The grant stays off once the update is done: what runs
keeps running, and the next install or update that asks again is refused.
shc config edit opens one scope’s config in your editor and writes back
what you save.
$ shc config edit --scope globalA service can also name the OCI runtime its node uses for it, such as
nvidia for a GPU, which needs the gpus class granted the same way. The
learning cluster has none.
services: infer: image: ollama/ollama:0.3 oci_runtime: nvidiaEvery Learn ladder is also a workshop. shc workshop learn-develop opens this
one in tmux, the pages on the left and a tab per node on the right, and
--list prints its pages and their blocks instead.
$ shc workshop learn-develop --list...$ shc workshop learn-developThat is the last page of this ladder. The Learn index lists the others.