diff options
| author | hc <hc@email.ch> | 2025-05-31 15:16:23 +0800 |
|---|---|---|
| committer | hc <hc@email.ch> | 2025-05-31 15:16:23 +0800 |
| commit | ce511f49438761549e904d6e972b8c0635306ff9 (patch) | |
| tree | 17ca3c8db244366a78e425b6456cdf7d602ca209 | |
| parent | 3a824121c7338ec395cf027156ea83f29fe1e6a4 (diff) | |
updateddocsandaddedclaudecode
| -rw-r--r-- | docker_build/Dockerfile | 16 | ||||
| -rw-r--r-- | docs | 52 | ||||
| -rw-r--r-- | rocky-ssh-deployment.yaml | 18 |
3 files changed, 44 insertions, 42 deletions
diff --git a/docker_build/Dockerfile b/docker_build/Dockerfile index f5d0a46..5df57d2 100644 --- a/docker_build/Dockerfile +++ b/docker_build/Dockerfile @@ -15,12 +15,10 @@ RUN mkdir -p /var/run/sshd && \ sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \ echo "AllowAgentForwarding yes" >> /etc/ssh/sshd_config - # Setup SSH directory for root and ensure root has valid shell RUN mkdir -p /root/.ssh && \ chmod 700 /root/.ssh && \ usermod -s /bin/bash root - # Copy SSH public keys from ssh-keys directory into the image COPY ssh-keys/*.pub /tmp/ssh-keys/ RUN cat /tmp/ssh-keys/*.pub > /root/.ssh/authorized_keys && \ @@ -41,6 +39,18 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ source "$HOME/.cargo/env" && \ cargo install cargo-clone-crate cargo-edit cargo-info evcxr_jupyter bacon du-dust +# Install Node.js via nvm and claude-code +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \ + export NVM_DIR="$HOME/.nvm" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + nvm install 22 && \ + npm install -g @anthropic-ai/claude-code + +# Add nvm to bashrc for future sessions +RUN echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \ + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc && \ + echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.bashrc + # Set working directory WORKDIR /root @@ -48,4 +58,4 @@ WORKDIR /root EXPOSE 22 # Start SSH daemon -CMD ["/usr/sbin/sshd", "-D", "-e"]
\ No newline at end of file +CMD ["/usr/sbin/sshd", "-D", "-e"] @@ -1,48 +1,40 @@ # Rocky SSH Container -Rocky Linux development environment with SSH access for Podman and Kubernetes. -## Launcher Commands +## Podman ```bash -# Check image status and show build commands -python3 launcher.py -python3 launcher.py run -python3 launcher.py run -p 2222 -python3 launcher.py list -python3 launcher.py cleanup +python3 podman_launch_devenv.py +python3 podman_launch_devenv.py run +python3 podman_launch_devenv.py run -p 2222 +python3 podman_launch_devenv.py list +python3 podman_launch_devenv.py cleanup ``` -## Kubernetes Commands +## Kubernetes ```bash kubectl apply -f rocky-ssh-deployment.yaml -# Check pods with IPs -kubectl get pods -l app=rocky-dev-deploy -o wide -# Check services (networking), get deployment is for stateless (not this) -kubectl get svc rocky-dev-deploy-svc -# Delete specific pod (auto-recreates) -kubectl delete pod rocky-dev-deploy-0 -# Scale replicas -kubectl scale statefulset rocky-dev-deploy --replicas=10 +kubectl get pods -l app=rocky-dev -o wide +kubectl get svc rocky-dev-svc +kubectl delete pod rocky-dev-0 +kubectl scale statefulset rocky-dev --replicas=10 kubectl delete -f rocky-ssh-deployment.yaml ``` -## Local Registry (for Kubernetes) +## Local Registry ```bash -# Run a local registry podman run -d -p 5000:5000 --name registry registry:2 -# Tag and push to local registry podman tag localhost/rocky_dev:latest localhost:5000/rocky_dev:latest podman push localhost:5000/rocky_dev:latest --tls-verify=false -# Update image in rocky-ssh-deployment.yaml to: localhost:5000/rocky_dev:latest ``` -## SSH Access +## Access ```bash -# Podman (launcher shows connection command) -ssh root@<host> -p <port> -# Kubernetes (port forward - localhost only) -kubectl port-forward <pod-name> 2222:22 -ssh root@localhost -p 2222 -# Kubernetes (port forward - external access) -kubectl port-forward --address 0.0.0.0 <pod-name> 9999:22 -ssh root@<host> -p 9999 +# Direct shell +kubectl exec -it rocky-dev-0 -- /bin/bash + +# SSH with agent forwarding (2 terminals) +kubectl port-forward rocky-dev-0 2222:22 +ssh-agent bash -c 'ssh-add ~/macm4-resident && ssh -A -p 2222 root@localhost' + +# External +kubectl port-forward --address 0.0.0.0 rocky-dev-0 9999:22 ``` diff --git a/rocky-ssh-deployment.yaml b/rocky-ssh-deployment.yaml index 61e0dc9..0d30e59 100644 --- a/rocky-ssh-deployment.yaml +++ b/rocky-ssh-deployment.yaml @@ -1,23 +1,23 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: rocky-dev-deploy + name: rocky-dev labels: - app: rocky-dev-deploy + app: rocky-dev spec: - serviceName: rocky-dev-deploy-svc - replicas: 3 + serviceName: rocky-dev-svc + replicas: 2 selector: matchLabels: - app: rocky-dev-deploy + app: rocky-dev template: metadata: labels: - app: rocky-dev-deploy + app: rocky-dev spec: containers: - - name: rocky-dev-deploy - image: localhost:5000/rocky_dev:latest + - name: rocky-dev + image: rocky_dev:latest imagePullPolicy: IfNotPresent # Use local image ports: - containerPort: 22 @@ -38,7 +38,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: rocky-dev-deploy-svc + name: rocky-dev-svc spec: clusterIP: None selector: |
