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 Admin Partitions when enabled #696

Merged
merged 5 commits into from
Sep 9, 2021
Merged

Conversation

thisisnotashwin
Copy link
Contributor

Changes proposed in this PR:

  • Create a partition when Admin Partitions are enabled.
  • The Kubernetes cluster that has servers (server cluster) will have clients installed in the default partition.
  • Workload clusters will have clients deployed in the partition whose name is provided in the values file.

How I've tested this PR:

  • Deployed the servers using this values file
global:
  tls:
    enabled: true
  image: ashwinvenkatesh/consul@sha256:08b61b39c2c45679f328ff618626540981261d37abb0e96246fa965f4c60e163
  imageK8S: ashwinvenkatesh/consul-k8s@sha256:fd9f407059514cc986369228f65d6ff3e127b9e37af0dd2513a494e12be3b5e3
  adminPartitions:
    enabled: true
server:
  exposeGossipAndRPCPorts: true
  enterpriseLicense:
    secretName: license
    secretKey: key
connectInject:
  enabled: true
controller:
  enabled: true
ui:
  service:
    type: NodePort
    nodePort:
      https: 30100

Things of note are this is a Consul Enterprise image and the license was provided as a secret. Additionally, an explicit nodePort has been assigned to the UI service. This is to expose Consul's https port.

Now, copy the TLS secrets and the Ent License to the workload-cluster.

global:
  enabled: false
  image: ashwinvenkatesh/consul@sha256:08b61b39c2c45679f328ff618626540981261d37abb0e96246fa965f4c60e163
  imageK8S: ashwinvenkatesh/consul-k8s@sha256:fd9f407059514cc986369228f65d6ff3e127b9e37af0dd2513a494e12be3b5e3
  adminPartitions:
    enabled: true
    name: "alpha"
  tls:
    enabled: true
    caCert:
      secretName: consul-consul-ca-cert
      secretKey: tls.crt
    caKey:
      secretName: consul-consul-ca-key
      secretKey: tls.key
server:
  enterpriseLicense:
    secretName: license
    secretKey: key
externalServers:
  enabled: true
  hosts: ["10.128.0.50"]
  httpsPort: 30100
  tlsServerName: server.dc1.consul
client:
  enabled: true
  exposeGossipPorts: true
  join:
  - "10.128.0.50"
  - "10.128.0.52"
  - "10.128.15.192"
connectInject:
  enabled: true
controller:
  enabled: true

The name of the partition here is "alpha". The ips specified under hosts and join are internal IPs for the nodes on GKE. the node IPs can be found using the kubectl get nodes -o wide command. Additionally, the firewalls rules on GKE needed to be updated to ensure that the node network and pod network from the server cluster and workload cluster could communicate all the nodes.

The clients logs in the server client state that they are in the default partition and the logs in the workload cluster state that they are in the alpha partition.
Validated the Connect works on the default cluster. Connect needs to make some changes in order for it to be supported on workload clusters and that is being worked on.

How I expect reviewers to test this PR:
Follow the above steps. DM me if you would like to pair on the above. Re-do the above steps and deploy "connect" apps in the default cluster.

Checklist:

  • Tests added
  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@thisisnotashwin thisisnotashwin requested review from a team, lkysow and sadjamz and removed request for a team August 30, 2021 18:56
- This removes any requirement on a post-install cleanup job.
Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

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

🎉 looking good

charts/consul/values.yaml Show resolved Hide resolved
control-plane/go.mod Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
enabled: false
# The name of the Admin Partition. Must be "default" in the server cluster ie the Kubernetes cluster that
# the Consul server pods are deployed onto.
name: "default"
Copy link
Member

Choose a reason for hiding this comment

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

Do you do any validation that if servers are enabled that this == default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not right now. I wanted to do this in a follow up task as it is not a must have. Have a task for it: https://app.asana.com/0/1200449541311255/1200910791029388/f

control-plane/subcommand/common/common.go Outdated Show resolved Hide resolved
control-plane/subcommand/common/common.go Outdated Show resolved Hide resolved
control-plane/subcommand/common/common.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/partition-init/command.go Outdated Show resolved Hide resolved
control-plane/subcommand/server-acl-init/command.go Outdated Show resolved Hide resolved
@thisisnotashwin thisisnotashwin requested review from ndhanushkodi and removed request for sadjamz September 8, 2021 16:44
Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

Looking awesome so far! I've just gotten through reviewing the Helm templates and some of the control-plane code and will continue tomorrow! Barely had comments because it's looking really great!

Other qs that popped up:
Do we explicitly require TLS to enable partitions or just highly recommend?

charts/consul/values.yaml Outdated Show resolved Hide resolved
@thisisnotashwin
Copy link
Contributor Author

Setting up external servers explicitly requires TLS. This is more a safety consideration as compared to Consul not working without it. So in a certain sense, we do not support non-TLS on k8s with externalServers. Are you thinking about adding that as an additional check?

Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

we do not support non-TLS on k8s with externalServers. Are you thinking about adding that as an additional check?
It could be worth the additional check, ok with that being a follow on task though!

Awesome work Ashwin!!!


// GetResolvedServerAddresses resolves the Consul server address if it has been provided a provider else it returns the server addresses that were input to it.
func GetResolvedServerAddresses(serverAddresses []string, providers map[string]discover.Provider, logger hclog.Logger) ([]string, error) {
if len(serverAddresses) != 1 || !strings.Contains(serverAddresses[0], "provider=") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was a little confused why it checking len != 1 and why serverAddresses could have a string "provider=" in it until I saw the test-- Maybe the comment could describe what the serverAddresses argument and providers argument could look like?

Could there be a case where there is exactly one server address that's not a provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing :)
There could be a case where we have a single address which is not a provider. For instance, with the Partition service, the single address would be the address of the partition service LB. Ill improve the text here.

Co-authored-by: Nitya Dhanushkodi <nitya@hashicorp.com>
@thisisnotashwin thisisnotashwin merged commit 8d0bcf1 into partitions Sep 9, 2021
@thisisnotashwin thisisnotashwin deleted the create-partition branch September 9, 2021 18:14
lawliet89 pushed a commit to lawliet89/consul-k8s that referenced this pull request Sep 13, 2021
This is because these tests are quite similar except for the
additional assertion in the health checks tests that asserts
that traffic is not routed when static-server probe fails.
This will save us quite a bit of run-time for both regular
and *namespace tests because the bulk of the test time is taken up
by the installs. This change essentially optimizes and re-uses existing
installs that we already have to do to test connect.
thisisnotashwin pushed a commit that referenced this pull request Sep 14, 2021
* Create Admin Partitions when enabled
thisisnotashwin pushed a commit that referenced this pull request Sep 14, 2021
* Create Admin Partitions when enabled
thisisnotashwin pushed a commit that referenced this pull request Sep 16, 2021
* Create Admin Partitions when enabled
thisisnotashwin pushed a commit that referenced this pull request Sep 17, 2021
* Create Admin Partitions when enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants