cloudfoundry / korifi

Cloud Foundry on Kubernetes
Apache License 2.0
311 stars 61 forks source link

[Chore]: deploy-on-kind script fails on MacOS Ventura #2054

Open tcdowney opened 1 year ago

tcdowney commented 1 year ago

Background

After upgrading to MacOS Ventura the deploy-on-kind.sh script began failing for me with the following error:

**************************
 Creating 'cf-admin' user
**************************
base64: invalid argument /var/folders/2t/k7bb02hx4lv_y740nrmk69v80000gn/T/tmp.lrbbJ092
Usage:  base64 [-hDd] [-b num] [-i in_file] [-o out_file]
  -h, --help     display this message
  -Dd, --decode   decodes input
  -b, --break    break encoded string into num character lines
  -i, --input    input file (default: "-" for stdin)
  -o, --output   output file (default: "-" for stdout)
The CertificateSigningRequest "ac5598ed9ab6a7e52441cff114b5604fcbf3db78" is invalid: spec.request: Invalid value: []byte{}: PEM block type must be CERTIFICATE REQUEST

This is due to a change in the base64 program that ships with newer MacOS versions. See: https://superuser.com/questions/1754224/what-is-the-difference-between-base64-b0-in-macos-versions-prior-to-macos-13

Action to take

I trivially fixed this on my machine by adding the -i flag to our cert creation logic in common.sh. To fix this for real we need to make sure it continues to work on other platforms which don't require or support the -i flag.

apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
  name: ${csr_name}
spec:
  signerName: "kubernetes.io/kube-apiserver-client"
  request: "$(base64 -i "${csr_file}" | tr -d "\n\r")"
  expirationSeconds: $((days * 24 * 60 * 60))
  usages:
  - client auth
EOF

Impact

Fixing this will allow users using newer MacOS versions to continue using the deploy-on-kind.sh script.

Dev Notes

No response

tcdowney commented 1 year ago

PR: https://github.com/cloudfoundry/korifi/pull/2055