|
1 | 1 | #!/bin/bash |
2 | | -set -x |
| 2 | +set -euo pipefail |
3 | 3 |
|
4 | | -curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH) |
5 | | -chmod +x ./kind |
6 | | -mv ./kind /usr/local/bin/kind |
| 4 | +echo "Installing Kubebuilder development tools..." |
7 | 5 |
|
8 | | -curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/$(go env GOARCH) |
9 | | -chmod +x kubebuilder |
10 | | -mv kubebuilder /usr/local/bin/ |
| 6 | +ARCH=$(go env GOARCH) |
11 | 7 |
|
12 | | -KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) |
13 | | -curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/$(go env GOARCH)/kubectl" |
14 | | -chmod +x kubectl |
15 | | -mv kubectl /usr/local/bin/kubectl |
| 8 | +# Install kind |
| 9 | +if ! command -v kind &> /dev/null; then |
| 10 | + curl -Lo ./kind "https://kind.sigs.k8s.io/dl/latest/kind-linux-${ARCH}" |
| 11 | + chmod +x ./kind |
| 12 | + mv ./kind /usr/local/bin/kind |
| 13 | +fi |
16 | 14 |
|
17 | | -docker network create -d=bridge --subnet=172.19.0.0/24 kind |
| 15 | +# Install kubebuilder |
| 16 | +if ! command -v kubebuilder &> /dev/null; then |
| 17 | + curl -L -o kubebuilder "https://go.kubebuilder.io/dl/latest/linux/${ARCH}" |
| 18 | + chmod +x kubebuilder |
| 19 | + mv kubebuilder /usr/local/bin/ |
| 20 | +fi |
18 | 21 |
|
| 22 | +# Install kubectl |
| 23 | +if ! command -v kubectl &> /dev/null; then |
| 24 | + KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) |
| 25 | + curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl" |
| 26 | + chmod +x kubectl |
| 27 | + mv kubectl /usr/local/bin/kubectl |
| 28 | +fi |
| 29 | + |
| 30 | +# Wait for Docker to be ready |
| 31 | +for i in {1..30}; do |
| 32 | + if docker info >/dev/null 2>&1; then |
| 33 | + break |
| 34 | + fi |
| 35 | + if [ $i -eq 30 ]; then |
| 36 | + echo "WARNING: Docker not ready after 30s" |
| 37 | + fi |
| 38 | + sleep 1 |
| 39 | +done |
| 40 | + |
| 41 | +# Create kind network, ignore errors if exists or conflicts |
| 42 | +docker network inspect kind >/dev/null 2>&1 || docker network create kind || true |
| 43 | + |
| 44 | +# Verify installations |
| 45 | +echo "Installed versions:" |
19 | 46 | kind version |
20 | 47 | kubebuilder version |
| 48 | +kubectl version --client |
21 | 49 | docker --version |
22 | 50 | go version |
23 | | -kubectl version --client |
| 51 | + |
| 52 | +echo "DevContainer ready!" |
0 commit comments