Skip to content

Commit e741bb5

Browse files
authored
Merge pull request #3606 from olamilekan000/add-lima-to-integrations
add lima integration step to doc
2 parents 5491074 + 2acb25c commit e741bb5

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

docs/content/setup/integrations.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,119 @@ them to OpenFGA queries.
5959

6060
!!! info "Third Party Solutions"
6161
A third-party example of such a webhook would be Platform Mesh's [rebac-authz-webhook](https://github.com/platform-mesh/rebac-authz-webhook).
62+
63+
## Lima
64+
You can run kcp inside a [Lima](https://github.com/lima-vm/lima)-managed VM, which makes it portable across macOS, Linux, and Windows (via WSL2). This setup gives you a disposable kcp control plane that integrates smoothly with your host kubectl.
65+
66+
!!! info "Development Use Only"
67+
This is essentially a development environment, where one can start a single instance of kcp for testing or limited-scope use cases. This is in no way intended for production usage.
68+
69+
Create a Lima template for kcp and save the following as `kcp.yaml`:
70+
```yaml
71+
minimumLimaVersion: 1.1.0
72+
73+
base: template://_images/ubuntu-lts
74+
75+
mounts: []
76+
77+
containerd:
78+
system: false
79+
user: false
80+
81+
provision:
82+
- mode: system
83+
script: |
84+
#!/bin/bash
85+
set -eux -o pipefail
86+
command -v kcp >/dev/null 2>&1 && exit 0
87+
88+
export DEBIAN_FRONTEND=noninteractive
89+
apt-get update
90+
apt-get install -y curl wget
91+
92+
KCP_VERSION=$(curl -s https://api.github.com/repos/kcp-dev/kcp/releases/latest | grep tag_name | cut -d '"' -f 4)
93+
KCP_VERSION_NO_V=${KCP_VERSION#v}
94+
95+
wget https://github.com/kcp-dev/kcp/releases/download/${KCP_VERSION}/kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
96+
tar -xzf kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
97+
mv bin/kcp /usr/local/bin/
98+
chmod +x /usr/local/bin/kcp
99+
rm -f kcp_${KCP_VERSION_NO_V}_linux_arm64.tar.gz
100+
101+
mkdir -p /var/.kcp/
102+
sudo chmod 755 /var/.kcp
103+
104+
cat > /etc/systemd/system/kcp.service << EOF
105+
[Unit]
106+
Description=kcp server
107+
After=network.target
108+
109+
[Service]
110+
Type=simple
111+
User=root
112+
ExecStart=/usr/local/bin/kcp start --root-directory=/var/.kcp/ --bind-address=127.0.0.1
113+
Restart=on-failure
114+
StandardOutput=journal
115+
StandardError=journal
116+
117+
[Install]
118+
WantedBy=multi-user.target
119+
EOF
120+
121+
systemctl daemon-reload
122+
systemctl enable kcp
123+
systemctl start kcp
124+
125+
probes:
126+
- script: |
127+
#!/bin/bash
128+
set -eux -o pipefail
129+
if ! timeout 120s bash -c "until curl -f -s --cacert /var/.kcp/apiserver.crt https://127.0.0.1:6443/readyz >/dev/null; do sleep 3; done"; then
130+
echo >&2 "kcp is not ready yet"
131+
exit 1
132+
fi
133+
hint: |
134+
The kcp control plane is not ready yet.
135+
Check the kcp logs with "limactl shell kcp sudo journalctl -f" or "tail -f /var/log/kcp.log"
136+
137+
copyToHost:
138+
- guest: "/var/.kcp/admin.kubeconfig"
139+
host: "{{ '{{.Dir}}' }}/copied-from-guest/kubeconfig.yaml"
140+
deleteOnStop: true
141+
142+
message: |
143+
To run `kubectl` on the host (assumes kubectl is installed), run:
144+
------
145+
export KUBECONFIG="{{ '{{.Dir}}' }}/copied-from-guest/kubeconfig.yaml"
146+
kubectl get workspaces
147+
------
148+
149+
```
150+
Initialize the VM
151+
```sh
152+
limactl create --name=kcp ./kcp.yaml
153+
```
154+
155+
Start the VM
156+
```sh
157+
limactl start kcp --vm-type=qemu
158+
```
159+
!!! info
160+
On macOS, Lima may default to vz (Apple Virtualization), while on Linux it defaults to qemu, and on Windows to wsl2. If you want consistency across environments, you can explicitly pass --vm-type=qemu when starting the VM.
161+
162+
Export the KCP kubeconfig
163+
```sh
164+
export KUBECONFIG="/Users/<user>/.lima/kcp/copied-from-guest/kubeconfig.yaml"
165+
```
166+
167+
Verify API resources
168+
```sh
169+
kubectl api-resources | grep kcp
170+
```
171+
You should see kcp-specific resources such as:
172+
```sh
173+
workspaces ws tenancy.kcp.io/v1alpha1 false Workspace
174+
logicalclusters core.kcp.io/v1alpha1 false LogicalCluster
175+
...
176+
```
177+

0 commit comments

Comments
 (0)