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

Support replacing kops secrets via force flag #3899

Merged

Conversation

KashifSaadat
Copy link
Contributor

  • Return an error when attempting to create a secret if it already exists (previously it would silently return with a successful exit code, which is misleading).
  • Allow passing a --force flag when creating encryptionconfig or dockerconfig secrets, so they can be replaced if they already exist.
  • Fixes Unable to update an existing kops secret with a new value #3895

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 21, 2017
@KashifSaadat
Copy link
Contributor Author

/assign @chrislovecnm @justinsb

What do you think, is this new behaviour ok or would you see it implemented differently?

Example usage:

➜  kops git:(kops-secret-force-update) ✗ kops create secret --name ${KOPS_CLUSTER_NAME} encryptionconfig -f encryptionConfigEnabled.yaml -v 10
s3context.go:163] Found bucket "${KOPS_BUCKET_NAME}" in region "${AWS_REGION}"
s3fs.go:176] Reading file "s3://${KOPS_BUCKET_NAME}/${KOPS_CLUSTER_NAME}/config"
s3fs.go:176] Reading file "s3://${KOPS_BUCKET_NAME}/${KOPS_CLUSTER_NAME}/secrets/encryptionconfig"

failed to create the encryptionconfig secret as it already exists. The `--force` flag can be passed to replace an existing secret.

➜  kops git:(kops-secret-force-update) ✗ echo $?
1

➜  kops git:(kops-secret-force-update) ✗ kops create secret --name ${KOPS_CLUSTER_NAME} encryptionconfig -f encryptionConfigEnabled.yaml --force -v 10
s3context.go:163] Found bucket "${KOPS_BUCKET_NAME}" in region "${AWS_REGION}"
s3fs.go:176] Reading file "s3://${KOPS_BUCKET_NAME}/${KOPS_CLUSTER_NAME}/config"
s3fs.go:113] Writing file "s3://${KOPS_BUCKET_NAME}/${KOPS_CLUSTER_NAME}/secrets/encryptionconfig"
s3fs.go:133] Calling S3 PutObject Bucket="${KOPS_BUCKET_NAME}" Key="${KOPS_CLUSTER_NAME}/secrets/encryptionconfig" SSE="AES256" ACL="" BodyLen=275
s3fs.go:176] Reading file "s3://${KOPS_BUCKET_NAME}/${KOPS_CLUSTER_NAME}/secrets/encryptionconfig"

➜  kops git:(kops-secret-force-update) ✗ echo $?
0

@@ -221,5 +236,8 @@ func (c *ClientsetSecretStore) createSecret(s *fi.Secret, name string) (*kops.Ke
PrivateMaterial: s.Data,
})

if replace {
return c.clientset.Keysets(c.namespace).Update(keyset)
Copy link
Member

Choose a reason for hiding this comment

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

Challenge here:I think Update fails if the secret doesn't exist. You would have to read it first.

@justinsb
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 21, 2017
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 21, 2017
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@justinsb
Copy link
Member

Opened #3902 to track that maybe-issue

@k8s-github-robot
Copy link

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit 0922f06 into kubernetes:master Nov 21, 2017
@KashifSaadat KashifSaadat deleted the kops-secret-force-update branch November 21, 2017 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants