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

create command to create new adminkubeconfig #1452

Merged

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Jun 12, 2023

Add oc config new-admin-kubeconfig to create a new admin.kubeconfig using an existing connection.

/assign @stlaz

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2023
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

I glanced at this, I just had some superficial nits, nonblocking.

newAdminKubeconfigLong = templates.LongDesc(i18n.T(`
Generate, make the server trust, and display a new admin.kubeconfig.

The key is produced locally and never hits disk. The public half is pushed to the cluster
Copy link
Member

Choose a reason for hiding this comment

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

s/never hits disk/is not persisted/ maybe? "hits disk" is a little colloquial.

Comment on lines 87 to 88
if len(args) > 0 {
fmt.Errorf("no arguments allowed")
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

	if err := cobra.ExactArgs(0)(cmd, args); err != nil {
		return err
	}

Doesn't seem to read easier to future maintainers to me.

}

// update the in-cluster configmap
existingConfigMap, err := r.KubeClient.CoreV1().ConfigMaps("openshift-config").Get(ctx, "admin-kubeconfig-client-ca", metav1.GetOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

A very minor style thing, I would hoist admin-kubeconfig-client-ca to a const at the top so it's easily found (and use it in multiple places to avoid typos).

}

func createNewAdminClientCert() (*crypto.TLSCertificateConfig, []byte, error) {
tenYears := 24 * time.Hour * 365 * 10
Copy link
Member

Choose a reason for hiding this comment

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

This would be a good toplevel const too

@deads2k
Copy link
Contributor Author

deads2k commented Jun 13, 2023

updated for comments.

Copy link
Member

@stlaz stlaz left a comment

Choose a reason for hiding this comment

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

no blocking comments

for i := range certificates {
found := false
for j := range finalCertificates {
if reflect.DeepEqual(certificates[i].Raw, finalCertificates[j].Raw) {
Copy link
Member

Choose a reason for hiding this comment

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

bytes.Equal would probably be good enough

}
}

caBytes, err := crypto.EncodeCertificates(finalCertificates...)
Copy link
Member

Choose a reason for hiding this comment

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

nit: you could just return here

@deads2k
Copy link
Contributor Author

deads2k commented Jun 13, 2023

/override ci/prow/e2e-agnostic-ovn-cmd

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 13, 2023

@deads2k: Overrode contexts on behalf of deads2k: ci/prow/e2e-agnostic-ovn-cmd

In response to this:

/override ci/prow/e2e-agnostic-ovn-cmd

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deads2k deads2k added lgtm Indicates that a PR is ready to be merged. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 13, 2023
@deads2k
Copy link
Contributor Author

deads2k commented Jun 13, 2023

got an lgtm via slack, labelling.

@deads2k
Copy link
Contributor Author

deads2k commented Jun 13, 2023

/override ci/prow/e2e-aws-ovn-serial

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 13, 2023

@deads2k: Overrode contexts on behalf of deads2k: ci/prow/e2e-aws-ovn-serial

In response to this:

/override ci/prow/e2e-aws-ovn-serial

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 13, 2023

@deads2k: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit db99e68 into openshift:master Jun 13, 2023
12 checks passed
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. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants