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 keystone with certificate #224

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

hidekazuna
Copy link
Contributor

What this PR does / why we need it:

This PR supports keystone endpoint with certificate by the following clouds.yaml with cacert key.

clouds:
  openstack:
    auth:
      auth_url: https://yourauthurl:5000/v3
      username: foo
      password: bar
      project_id: foobar123
      project_name: foobar
      user_domain_name: "Default"
    cacert: /path/to/cacertfile
    region_name: "Region_1"
    interface: "public"
    identity_api_version: 3

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #209

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 12, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @hidekazuna. Thanks for your PR.

I'm waiting for a kubernetes-sigs or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 12, 2019
@jichenjc
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 12, 2019
transport := &http.Transport{TLSClientConfig: tlsConfig}
client.HTTPClient = http.Client{Transport: transport}

err = openstack.Authenticate(client, *ao)
Copy link
Contributor

Choose a reason for hiding this comment

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

forgive me if I misunderstand something here.. I believe https need ca and http doesn't need it
from context we are requesting that to be mandatory https ,maybe I missed something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. I should have update code https is not mandatory. I will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the following commit: 192e70c

@hidekazuna hidekazuna force-pushed the keystone_cacert branch 3 times, most recently from f172002 to 1a44f4e Compare February 14, 2019 01:45
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2019
@hidekazuna hidekazuna force-pushed the keystone_cacert branch 3 times, most recently from f4901b3 to 41b7b6c Compare February 19, 2019 07:12
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 6, 2019
@@ -143,7 +144,7 @@ PASSWORD=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN" | yq r - clouds.$CLOUD.auth.pass
REGION=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN" | yq r - clouds.$CLOUD.region_name)
PROJECT_ID=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN" | yq r - clouds.$CLOUD.auth.project_id)
DOMAIN_NAME=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN" | yq r - clouds.$CLOUD.auth.user_domain_name)

CACERT_ORIGINAL=$(echo "$OPENSTACK_CLOUD_CONFIG_PLAIN" | yq r - clouds.$CLOUD.cacert)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be problem if cacert doesn't exist...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the following commit: 192e70c


cloudFromYaml, err := clientconfig.GetCloudFromYAML(clientOpts)
if cloudFromYaml.CACertFile != "" {
roots, err := certutil.NewPool(caFile)
Copy link

Choose a reason for hiding this comment

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

I am thinking about the mounted caFile here. In theory, the entire code allows us to use a separate clouds.yaml per machine. But it is only possible to pass in a caFile for all machines.

How about extending the cloud-config secret with another field for the contents of the caFile.... and create a separate x509.CertPool from this secret?

I think it would be ok to extend the cloud-config secret, because it relates directly to the clouds.yaml, rather than having a separate secret.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hidekazuna @gyliu513 provided this to me
master...cdc1807:cacert-auth

I think we can try to refer to this one, at least it works for me now on a https openstack and I think we can use secret to replace the CACERT in the commit diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jichenjc Thanks advice.
I updated like this: 672c5af#diff-6f1595bb05179a80513b3baba49fbaf1R58
I noticed I need to update getNetworkClient function in pkg/cloud/openstack/cluster/actuator.go.
But I wonder how to fix this function as well. Could you advice?

Copy link
Contributor

Choose a reason for hiding this comment

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

I might need more time to figure out but FYI https://github.com/kubernetes/cloud-provider-openstack has a set of https handling including network, maybe we can refer to their implementation @hidekazuna

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chrigl @jichenjc getNetworkClient is the method of Actuator in cluster package and it's augment is *clusterv1.Cluster. We can not secrets from Actuator nor clusterv1.Cluster. I thinks this is from design issue.
Since we have to create a CA file for using OpenStack Cloud provider anyway, can't we make a compromise to use CA file?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not aware clusterv1 can't use secrets from Actuator, ... but conceptually yes, if you want to sync cluster to create network, apparently we need CA in order to connect to openstack, so I think it's mandatory to use CA in actuator, can we define in openstackclusterspec for this ? @hidekazuna

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jichenjc Thanks, now I am trying to update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jichenjc I updated by 0bf8a1b

pkg/cloud/openstack/clients/machineservice.go Outdated Show resolved Hide resolved
@morvencao
Copy link

/cc

@k8s-ci-robot
Copy link
Contributor

@morvencao: GitHub didn't allow me to request PR reviews from the following users: morvencao.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2019
@hchenxa
Copy link
Contributor

hchenxa commented Apr 25, 2019

@gyliu513 @jichenjc , I create create the VM with cacert now.

@gyliu513
Copy link
Contributor

Thanks @hchenxa

/lgtm

/cc @jichenjc @chrigl

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 25, 2019
@@ -79,6 +79,8 @@ CLUSTER_DNS_SERVER=$(prips ${SERVICE_CIDR} | head -n 11 | tail -n 1)

# Write the cloud.conf so that the kubelet can use it.
echo $OPENSTACK_CLOUD_PROVIDER_CONF | base64 -d > /etc/kubernetes/cloud.conf
mkdir /etc/certs
echo $OPENSTACK_CLOUD_CACERT_CONFIG | base64 -d > /etc/certs/cacert
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious
this is only for ubuntu, do we have a centos version? I didn't see it ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks added this for centos.

@@ -186,14 +199,17 @@ if [[ "$PROVIDER_OS" == "coreos" ]]; then
else
Copy link
Contributor

Choose a reason for hiding this comment

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

you updated centos and ubuntu
but how about coreos ? I didn't see the change ,maybe a follow up??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I Updated files for coreos.

@jichenjc
Copy link
Contributor

thanks @hchenxa and @hidekazuna
I think we may leave this for a few days to get some opinion then we can merge it

in addition, I had some comments above, can you help to take a look @hidekazuna ? thank you

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 26, 2019
@gyliu513
Copy link
Contributor

@hidekazuna make generate_yaml_test failed, can you help check?

mv kustomize_1.0.11_linux_amd64 /usr/local/bin/kustomize
chmod +x /usr/local/bin/kustomize
# Create a dummy file for test only
echo 'clouds' > dummy-clouds-test.yaml
cmd/clusterctl/examples/openstack/generate-yaml.sh -f dummy-clouds-test.yaml openstack ubuntu dummy-make-auto-test
Generating SSH key files for machine controller.
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/openstack_tmp.
Your public key has been saved in /root/.ssh/openstack_tmp.pub.
The key fingerprint is:
SHA256:L90G006kSqwbMxM0lT0drVo+4bXNMIGj7bsPZaG91j8 root@5807cc27-67fb-11e9-be50-0a580a6c05bf
The key's randomart image is:
+---[RSA 2048]----+
|        .o ..+   |
|       .. o + o  |
|      o    +.o.. |
|     . o  .+=o+. |
|      . S +*+o+* |
|       + +.*=o.oo|
|      * o o =oo .|
|       * . ..o E.|
|      .     .o. o|
+----[SHA256]-----+
cat: null: No such file or directory
Makefile:78: recipe for target 'generate_yaml_test' failed
make: *** [generate_yaml_test] Error 1
+ EXIT_VALUE=2
+ set +o xtrace

@hidekazuna
Copy link
Contributor Author

/test pull-cluster-api-provider-openstack-test

@jichenjc
Copy link
Contributor

copy the link I added in the slack channel :)

@hidekazuna the #224 failed with a new test I added recently #322, at least it works when I submit the PR with my local stuffs and gate, please let me know whether some edge case triggered by your PR and any info needed by me ,thanks

@jichenjc
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 27, 2019
@jichenjc
Copy link
Contributor

I think we are ready for this one, as the @hchenxa already tested it

@gyliu513
Copy link
Contributor

LGTM

Leave this to @chrigl for approve.

@gyliu513
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gyliu513, hidekazuna

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2019
@k8s-ci-robot k8s-ci-robot merged commit dc0834e into kubernetes-sigs:master Apr 29, 2019
@hidekazuna hidekazuna deleted the keystone_cacert branch May 9, 2019 04:24
iamemilio pushed a commit to iamemilio/cluster-api-provider-openstack that referenced this pull request Jun 14, 2019
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Support keystone endpoint with certificate
7 participants