Trusting the object store CA in the storage service

Add the CA of the object store S3 gateway to the abs storage service trust bundle so that the storage leaves the Degraded state.

In this procedure, you add the CA of the object store S3 gateway to the trust bundle of the abs storage service. The abs service is written in Go and trusts only the CAs in the file named by SSL_CERT_FILE. If the CA of the object store gateway is missing, the storage ends in the Degraded state, and curl in the abs Pod reports ssl_verify=20.

  • You have administrator kubeconfig files for the Cloudera Cloud Factory console cluster and for the cluster that runs the object store.
  • You know the object store endpoint.
  1. Define the helper functions and the endpoint.
    kcc(){ kubectl --request-timeout=30s --kubeconfig "$CONSOLE_KC" "$@"; }
    kcs(){ kubectl --request-timeout=30s --kubeconfig "$COS_KC" "$@"; }
    EP=<object-store-endpoint>
  2. Get the CA that signed the endpoint certificate, and verify it.
    kcs get clusterissuer ca-key-pair -o jsonpath='{.spec.ca.secretName}'
    
    kcs -n cert-manager get secret <secret-name> -o jsonpath='{.data.tls\.crt}' | base64 -d > awc-operators-ca.pem
    
    openssl s_client -connect $EP:443 -servername $EP -showcerts </dev/null 2>/dev/null | openssl x509 > endpoint-leaf.pem
    
    openssl verify -CAfile awc-operators-ca.pem endpoint-leaf.pem
    
    openssl x509 -in awc-operators-ca.pem -noout -subject -fingerprint -sha256

    The verification must print OK. Never use the leaf certificate alone as the trust root.

  3. Check the current trust.
    kcc -n abs exec deploy/abs -- sh -c 'echo $SSL_CERT_FILE'
    
    kcc -n awc-core get helmrelease awc-abs -o jsonpath='{.spec.values.volumes}{"\n"}{.spec.values.volumeMounts}{"\n"}'
    
    kcc -n abs exec deploy/abs -- curl -sS -o /dev/null -w 'ssl_verify=%{ssl_verify_result} http=%{http_code}\n' https://$EP/

    If ssl_verify is 0, the CA is already trusted, and you stop. If it is 20, the CA is missing. Use the output of the first two commands to choose a case. In case A, the variable is empty and the service uses /etc/ssl/certs/ca-certificates.crt. In case B, SSL_CERT_FILE is /etc/ssl/certs/ccf-trust-bundle/ca.crt.

  4. Back up the HelmRelease, and build the new bundle.

    For case B:

    kcc -n awc-core get helmrelease awc-abs -o yaml > abs-before.yaml
    
    kcc -n abs get cm ccf-trust-bundle -o jsonpath='{.data.ca\.crt}' > ccf-trust-bundle-original.crt
    
    cp ccf-trust-bundle-original.crt abs-trust-bundle.crt
    
    echo >> abs-trust-bundle.crt && cat awc-operators-ca.pem >> abs-trust-bundle.crt
    
    grep -c 'BEGIN CERTIFICATE' abs-trust-bundle.crt

    The count must be the original count plus one. For case A, read the Pod bundle instead, and append the CA in the same way:

    kcc -n abs exec deploy/abs -- cat /etc/ssl/certs/ca-certificates.crt > abs-pod-ca.crt
  5. Create the ConfigMap abs-trust-bundle. The key is ca.crt for case B and ca-certificates.crt for case A.
    kcc -n abs create configmap abs-trust-bundle --from-file=ca.crt=abs-trust-bundle.crt --dry-run=client -o yaml | kcc apply -f -
  6. Patch the HelmRelease. For case B, send the complete values.volumes list with the trust volume pointing to the abs-trust-bundle ConfigMap, and send the unchanged values.volumeMounts.
    kcc -n awc-core patch helmrelease awc-abs --type merge -p '{"spec":{"values":{"volumes":[<complete-volume-list>]}}}'

    For case A, append the volume {"name":"abs-trust-bundle","configMap":{"name":"abs-trust-bundle"}} to values.volumes, and the mount {"name":"abs-trust-bundle","mountPath":"/etc/ssl/certs/ca-certificates.crt","subPath":"ca-certificates.crt","readOnly":true} to values.volumeMounts.

  7. Wait for the rollout.
    kcc -n abs rollout status deploy/abs --timeout=300s
  8. Verify the trust.
    kcc -n abs exec deploy/abs -- sh -c 'grep -c "BEGIN CERT" $SSL_CERT_FILE'
    
    kcc -n abs exec deploy/abs -- curl -sS -o /dev/null -w 'ssl_verify=%{ssl_verify_result} http=%{http_code}\n' https://$EP/

    The result must be ssl_verify=0. An HTTP status of 403 without credentials is acceptable.

  9. Register the storage service in the console.

The abs service trusts the object store CA, and the storage leaves the Degraded state.

Rolling back. Patch the original values.volumes and values.volumeMounts from abs-before.yaml, and wait for the rollout. Delete the ConfigMap abs-trust-bundle only after the rollout, and only if you created it.