Last active
March 22, 2025 16:37
-
-
Save chrishham/f42b60ffe80a7239b675851c04c8292c to your computer and use it in GitHub Desktop.
setup-cx32.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Ask for password | |
read -s -p "Enter password for code server: " USER_PASSWORD </dev/tty | |
echo | |
# Install K3s | |
curl -sfL https://get.k3s.io | sh - | |
# Adjust permissions for K3s config | |
sudo chmod 644 /etc/rancher/k3s/k3s.yaml | |
# Set KUBECONFIG environment variable | |
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc | |
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml | |
source ~/.bashrc | |
# Verify K3s installation | |
sudo systemctl status k3s --no-pager | |
kubectl get nodes | |
# Install Helm | |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
# Install ArgoCD | |
kubectl create namespace argocd | |
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | |
# Install ArgoCD CLI | |
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 | |
chmod +x argocd | |
sudo mv argocd /usr/local/bin/ | |
# Install Istio | |
curl -L https://istio.io/downloadIstio | sh - | |
cd istio-* | |
sudo mv bin/istioctl /usr/local/bin/ | |
hash -r | |
istioctl install --set profile=demo -y | |
cd .. | |
rm -rf istio-* | |
# Install code-server | |
curl -fsSL https://code-server.dev/install.sh | sh | |
# Configure code-server | |
mkdir -p ~/.config/code-server | |
echo "bind-addr: 0.0.0.0:8888" > ~/.config/code-server/config.yaml | |
echo "auth: password" >> ~/.config/code-server/config.yaml | |
echo "password: \"$USER_PASSWORD\"" >> ~/.config/code-server/config.yaml | |
echo "cert: false" >> ~/.config/code-server/config.yaml | |
# Enable and start code-server | |
sudo systemctl enable --now code-server@$(whoami) | |
# Install Docker | |
# Add Docker's official GPG key: | |
sudo apt-get update | |
sudo apt-get install ca-certificates curl | |
sudo install -m 0755 -d /etc/apt/keyrings | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
# Add the repository to Apt sources: | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ | |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
sudo usermod -aG docker $USER | |
newgrp docker | |
# Verification and status output | |
check_service() { | |
if systemctl is-active --quiet "$1"; then | |
echo -e "✔ $1 is running" | |
else | |
echo -e "✘ $1 is NOT running" | |
fi | |
} | |
echo -e "\nVerifying installed services..." | |
check_service k3s | |
check_output() { | |
if [ $? -eq 0 ]; then | |
echo -e "✔ $1 is running successfully" | |
else | |
echo -e "✘ $1 failed to start" | |
fi | |
} | |
# Verify Helm | |
if helm version &>/dev/null; then | |
echo -e "✔ Helm is installed and working" | |
else | |
echo -e "✘ Helm is NOT working" | |
fi | |
echo "Checking ArgoCD status..." | |
kubectl get pods -n argocd &>/dev/null && echo -e "✔ ArgoCD is running" || echo -e "✘ ArgoCD is NOT running" | |
echo "Checking Istio status..." | |
kubectl get pods -n istio-system | grep -q istiod && echo -e "✔ Istio is running" || echo -e "✘ Istio is NOT running" | |
echo "Checking Code-Server status..." | |
check_service code-server@$(whoami) | |
echo "Setup and verification completed." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment