Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more portable invocation of base64 tool #48591

Closed
wants to merge 1 commit into from

Conversation

ayushpatil2122
Copy link
Contributor

Description

kubectl get csr my-svc.my-namespace -o json | \
  jq '.status.certificate = "'$(base64 ca-signed-server.pem | tr -d '\n')'"' | \
  kubectl replace --raw /apis/certificates.k8s.io/v1/certificatesigningrequests/my-svc.my-namespace/status -f -

During the "Upload the signed certificate" step (https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/#upload-the-signed-certificate) the command didn't work without the "-i" option using the base64 command.

it had to be

kubectl get csr my-svc.my-namespace -o json | \
  jq '.status.certificate = "'$(base64 -i ca-signed-server.pem | tr -d '\n')'"' | \
  kubectl replace --raw /apis/certificates.k8s.io/v1/certificatesigningrequests/my-svc.my-namespace/status -f -

Issue

#48586

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign salaxander for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the language/en Issues or PRs related to English language label Oct 29, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 29, 2024
Copy link

netlify bot commented Oct 29, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit a260ccc
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/67212eefb5b5000008fb108d
😎 Deploy Preview https://deploy-preview-48591--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@thisisharrsh
Copy link
Contributor

As mentioned in the comment (#48586 (comment)), It will be better if we could add a note. 

@sftim
Copy link
Contributor

sftim commented Oct 30, 2024

/retitle Use more portable invocation of base64 tool

@k8s-ci-robot k8s-ci-robot changed the title Upload the signed certificate the command didn't work without the "-i… Use more portable invocation of base64 tool Oct 30, 2024
@@ -262,7 +262,7 @@ Finally, populate the signed certificate in the API object's status:

```shell
kubectl get csr my-svc.my-namespace -o json | \
jq '.status.certificate = "'$(base64 ca-signed-server.pem | tr -d '\n')'"' | \
jq '.status.certificate = "'$(base64 -i ca-signed-server.pem | tr -d '\n')'"' | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the BSD version of base64 included with macOS, -i means "input file". It does not take a positional input file argument.
With the gnu version in most linux distros, -i is short for --ignore-garbage. It does allow for a positional input file argument.

There shouldn't be any "garbage" in the pem file, but it looks safe to use it to be compatible with either implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We could add a comment (shell comment) to explain what's going on here. Otherwise, another contributor may come and "fix" it.
  • We could use tabs for "Linux", "macOS" and "Windows" with the appropriate commands to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants