diff --git a/.kustomization.yaml b/.kustomization.yaml index 3fe2ef4..ee93de0 100644 --- a/.kustomization.yaml +++ b/.kustomization.yaml @@ -7,9 +7,6 @@ resources: # Namespace - namespace.yaml - # Harbor Certificate Configuration (DaemonSet) - - mcp-servers/containerd-harbor-cert-config-daemonset.yaml - # Proxmox VE MCP - mcp-servers/proxmox-ve-mcp/deployment.yaml - mcp-servers/proxmox-ve-mcp/service.yaml diff --git a/README.md b/README.md index ef4a66a..77d6527 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,13 @@ All resources are deployed to the `mcp-servers` namespace, which is created auto All deployments are configured to use Harbor registry (`harbor.dataknife.net`) and require authentication to pull images. The `harbor-registry-secret` must be created in the `mcp-servers` namespace before deploying. +Harbor serves a Let's Encrypt certificate, so nodes trust it via the public CA chain — there is no custom Harbor CA DaemonSet (`containerd-harbor-cert-config`) or `harbor-ca-cert` secret in this repo. If Fleet `keepResources: true` leaves those objects on **prd-apps** after sync, delete them manually in `mcp-servers`: + +```bash +kubectl delete daemonset containerd-harbor-cert-config -n mcp-servers --context=prd-apps --ignore-not-found +kubectl delete secret harbor-ca-cert -n mcp-servers --context=prd-apps --ignore-not-found +``` + **Creating the Harbor Registry Secret**: ```bash kubectl create secret docker-registry harbor-registry-secret \ diff --git a/fleet.yaml b/fleet.yaml index 0f7c4e6..d6a73f4 100644 --- a/fleet.yaml +++ b/fleet.yaml @@ -11,6 +11,10 @@ # - Fleet can apply Kubernetes manifests directly without Kustomize # - Individual resource files are self-contained and valid # +# Harbor (harbor.dataknife.net) uses Let's Encrypt — no custom CA DaemonSet. +# GitRepo keepResources: true may leave orphaned containerd-harbor-cert-config / +# harbor-ca-cert on prd-apps after this repo drops them; delete manually if needed. +# # For local kustomize usage: # mv .kustomization.yaml kustomization.yaml # kubectl kustomize . diff --git a/mcp-servers/containerd-harbor-cert-config-daemonset.yaml b/mcp-servers/containerd-harbor-cert-config-daemonset.yaml deleted file mode 100644 index c3c48fc..0000000 --- a/mcp-servers/containerd-harbor-cert-config-daemonset.yaml +++ /dev/null @@ -1,158 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: containerd-harbor-cert-config - namespace: mcp-servers - labels: - app: containerd-harbor-cert-config - component: mcp-infrastructure - managed-by: gitops -spec: - revisionHistoryLimit: 10 - selector: - matchLabels: - app: containerd-harbor-cert-config - template: - metadata: - labels: - app: containerd-harbor-cert-config - component: mcp-infrastructure - managed-by: gitops - spec: - imagePullSecrets: - - name: harbor-registry-secret - containers: - - name: cert-config - image: harbor.dataknife.net/dockerhub/library/alpine:latest - imagePullPolicy: Always - command: - - /bin/sh - - -c - - | - set -e - - HARBOR_URL="harbor.dataknife.net" - MOUNTED_CERT="/cert/ca.crt" - - # RKE2 registry configuration paths - RKE2_REGISTRY_DIR="/etc/rancher/rke2" - RKE2_REGISTRY_YAML="${RKE2_REGISTRY_DIR}/registries.yaml" - RKE2_CERT_FILE="${RKE2_REGISTRY_DIR}/harbor-ca.crt" - - # Also configure containerd certs.d directory (backup method) - CONTAINERD_CERTS_DIR="/var/lib/rancher/rke2/agent/etc/containerd/certs.d/${HARBOR_URL}" - CONTAINERD_CERT_FILE="${CONTAINERD_CERTS_DIR}/ca.crt" - - echo "Configuring RKE2 to trust Harbor registry certificate..." - echo "RKE2 registry config: ${RKE2_REGISTRY_YAML}" - echo "RKE2 certificate file: ${RKE2_CERT_FILE}" - echo "Mounted certificate: ${MOUNTED_CERT}" - - # Check if mounted certificate exists - if [ ! -f "${MOUNTED_CERT}" ]; then - echo "Error: Mounted certificate not found at ${MOUNTED_CERT}" - exit 1 - fi - - # Create RKE2 registry directory - echo "Creating RKE2 registry directory: ${RKE2_REGISTRY_DIR}" - mkdir -p "${RKE2_REGISTRY_DIR}" - - # Copy certificate for RKE2 registries.yaml - echo "Copying certificate to ${RKE2_CERT_FILE}" - cp "${MOUNTED_CERT}" "${RKE2_CERT_FILE}" - chmod 644 "${RKE2_CERT_FILE}" - - # Create RKE2 registries.yaml configuration - echo "Creating RKE2 registries.yaml configuration..." - cat > "${RKE2_REGISTRY_YAML}" < "${RKE2_REGISTRY_YAML}" < /dev/null; then - echo -e "${RED}❌ Error: kubectl is not installed${NC}" - exit 1 -fi - -# Check if context exists -if ! kubectl config get-contexts "$CONTEXT" &> /dev/null; then - echo -e "${RED}❌ Error: Kubernetes context '$CONTEXT' not found${NC}" - exit 1 -fi - -echo -e "${BLUE}🔧 RKE2 Service Restart Script${NC}" -echo "==================================" -echo "Context: $CONTEXT" -echo "SSH User: $SSH_USER" -echo "Namespace: $NAMESPACE" -echo "" - -# Wait for DaemonSet to be ready -echo -e "${BLUE}📋 Checking DaemonSet status...${NC}" -if ! kubectl get daemonset containerd-harbor-cert-config -n "$NAMESPACE" --context="$CONTEXT" &> /dev/null; then - echo -e "${YELLOW}⚠️ Warning: containerd-harbor-cert-config DaemonSet not found in namespace $NAMESPACE${NC}" - echo "Please ensure the DaemonSet is deployed first." - exit 1 -fi - -READY=$(kubectl get daemonset containerd-harbor-cert-config -n "$NAMESPACE" --context="$CONTEXT" -o jsonpath='{.status.numberReady}') -DESIRED=$(kubectl get daemonset containerd-harbor-cert-config -n "$NAMESPACE" --context="$CONTEXT" -o jsonpath='{.status.desiredNumberScheduled}') - -if [ "$READY" != "$DESIRED" ]; then - echo -e "${YELLOW}⚠️ Warning: DaemonSet not fully ready ($READY/$DESIRED pods ready)${NC}" - read -p "Continue anyway? (y/N): " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi -else - echo -e "${GREEN}✅ DaemonSet is ready ($READY/$DESIRED pods)${NC}" -fi - -echo "" -echo -e "${BLUE}📋 Getting node list...${NC}" - -# Get nodes and determine their roles -NODES=$(kubectl get nodes --context="$CONTEXT" -o json | jq -r '.items[] | "\(.metadata.name)|\(if .metadata.labels."node-role.kubernetes.io/control-plane" then "control-plane" else "worker" end)"') - -if [ -z "$NODES" ]; then - echo -e "${RED}❌ Error: No nodes found in cluster${NC}" - exit 1 -fi - -# Process each node -SUCCESS_COUNT=0 -FAILED_NODES=() - -while IFS='|' read -r NODE_NAME NODE_ROLE; do - # Determine service name - if [ "$NODE_ROLE" == "control-plane" ]; then - SERVICE="rke2-server" - NODE_TYPE="control-plane" - else - SERVICE="rke2-agent" - NODE_TYPE="worker" - fi - - echo "" - echo -e "${BLUE}🔄 Processing node: ${NODE_NAME} (${NODE_TYPE})${NC}" - echo " Service: $SERVICE" - - # Try to get node IP - NODE_IP=$(kubectl get node "$NODE_NAME" --context="$CONTEXT" -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}' 2>/dev/null || echo "") - - if [ -z "$NODE_IP" ]; then - # Fallback: try ExternalIP - NODE_IP=$(kubectl get node "$NODE_NAME" --context="$CONTEXT" -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}' 2>/dev/null || echo "") - fi - - if [ -z "$NODE_IP" ]; then - echo -e "${YELLOW}⚠️ Warning: Could not determine node IP, using hostname: $NODE_NAME${NC}" - SSH_TARGET="$NODE_NAME" - else - SSH_TARGET="$NODE_IP" - echo " IP: $NODE_IP" - fi - - # SSH and restart service - echo -e "${BLUE} SSH to $SSH_TARGET and restart $SERVICE...${NC}" - - if ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$SSH_USER@$SSH_TARGET" "sudo systemctl restart $SERVICE && sudo systemctl status $SERVICE --no-pager -l" 2>&1; then - echo -e "${GREEN} ✅ Successfully restarted $SERVICE on $NODE_NAME${NC}" - SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) - else - echo -e "${RED} ❌ Failed to restart $SERVICE on $NODE_NAME${NC}" - FAILED_NODES+=("$NODE_NAME") - fi - -done <<< "$NODES" - -echo "" -echo -e "${BLUE}==================================${NC}" -echo -e "${BLUE}Summary${NC}" -echo "==================================" -echo "Total nodes processed: $(echo "$NODES" | wc -l)" -echo -e "${GREEN}Successful: $SUCCESS_COUNT${NC}" -if [ ${#FAILED_NODES[@]} -gt 0 ]; then - echo -e "${RED}Failed: ${#FAILED_NODES[@]}${NC}" - echo "Failed nodes:" - for node in "${FAILED_NODES[@]}"; do - echo " - $node" - done - exit 1 -else - echo -e "${GREEN}✅ All nodes processed successfully!${NC}" - echo "" - echo "Next steps:" - echo "1. Wait a few minutes for RKE2 services to fully restart" - echo "2. Check pod status: kubectl get pods -n $NAMESPACE --context=$CONTEXT" - echo "3. Verify image pulls are working" -fi