diff --git a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml b/k8s/apps/pasarguard/configmap-scripts-ingress.yaml deleted file mode 100644 index 2215cfa..0000000 --- a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml +++ /dev/null @@ -1,212 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: pasarguard-scripts-ingress - labels: - app: pasarguard-node-ingress -data: - init-uuid-ingress.sh: | - #!/bin/bash - set -e - echo "Started" - # NODE_NAME is already set via environment variable - NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) - - # Get DNS name from node label xray-public-address - DNS_NAME=$(kubectl get node "${NODE_NAME}" -o jsonpath='{.metadata.labels.xray-public-address}') - - if [ -z "${DNS_NAME}" ]; then - echo "ERROR: Node ${NODE_NAME} does not have label 'xray-public-address'" - exit 1 - fi - - echo "Node: ${NODE_NAME}" - echo "DNS Name from label: ${DNS_NAME}" - - # Use DNS name for ConfigMap name to ensure uniqueness - CONFIGMAP_NAME="node-uuid-ingress-${DNS_NAME//./-}" - - echo "Checking ConfigMap: ${CONFIGMAP_NAME}" - - # Check if ConfigMap exists and get UUID - if kubectl get configmap "${CONFIGMAP_NAME}" -n "${NAMESPACE}" &>/dev/null; then - echo "ConfigMap exists, reading UUID..." - API_KEY=$(kubectl get configmap "${CONFIGMAP_NAME}" -n "${NAMESPACE}" -o jsonpath='{.data.API_KEY}') - - if [ -z "${API_KEY}" ]; then - echo "UUID not found in ConfigMap, generating new one..." - API_KEY=$(cat /proc/sys/kernel/random/uuid) - kubectl patch configmap "${CONFIGMAP_NAME}" -n "${NAMESPACE}" --type merge -p "{\"data\":{\"API_KEY\":\"${API_KEY}\"}}" - else - echo "Using existing UUID from ConfigMap" - fi - else - echo "ConfigMap does not exist, creating new one..." - API_KEY=$(cat /proc/sys/kernel/random/uuid) - kubectl create configmap "${CONFIGMAP_NAME}" -n "${NAMESPACE}" \ - --from-literal=API_KEY="${API_KEY}" \ - --from-literal=NODE_NAME="${NODE_NAME}" - fi - - # Save UUID and node info to shared volume for the main container - echo -n "${API_KEY}" > /shared/api-key - echo -n "${NODE_NAME}" > /shared/node-name - echo -n "${CONFIGMAP_NAME}" > /shared/configmap-name - echo "UUID initialized: ${API_KEY}" - echo "Node name: ${NODE_NAME}" - echo "ConfigMap: ${CONFIGMAP_NAME}" - - # Create Certificate for this node using DNS name from label - CERT_NAME="pasarguard-node-ingress-${DNS_NAME//./-}" - - echo "Creating Certificate: ${CERT_NAME} for ${DNS_NAME}" - - # Check if Certificate already exists - if ! kubectl get certificate "${CERT_NAME}" -n "${NAMESPACE}" &>/dev/null; then - echo "Certificate does not exist, creating..." - cat </dev/null; then - echo "Certificate secret is ready!" - break - fi - echo "Waiting for certificate... ($i/600)" - sleep 1 - done - - if ! kubectl get secret "${CERT_NAME}-tls" -n "${NAMESPACE}" &>/dev/null; then - echo "WARNING: Certificate secret not ready after 600 seconds" - else - # Extract certificate and key from secret to shared volume - echo "Extracting certificate and key..." - kubectl get secret "${CERT_NAME}-tls" -n "${NAMESPACE}" -o jsonpath='{.data.tls\.crt}' | base64 -d > /shared/tls.crt - kubectl get secret "${CERT_NAME}-tls" -n "${NAMESPACE}" -o jsonpath='{.data.tls\.key}' | base64 -d > /shared/tls.key - echo "Certificate and key extracted successfully." - cat /shared/tls.crt - fi - - # Create ClusterIP Service for this node (pod selector based) - NODE_SHORT_NAME="${NODE_NAME%%.*}" - SERVICE_NAME="${NODE_SHORT_NAME}-ingress" - - echo "Creating Service: ${SERVICE_NAME} for node ${NODE_NAME} (short: ${NODE_SHORT_NAME})" - - # Create Service with pod selector including node name - cat <