Skip to content

Commit

Permalink
Merge controller subcommand into connect inject subcommand.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnotashwin committed Nov 10, 2022
1 parent 706fb91 commit 437eee1
Show file tree
Hide file tree
Showing 84 changed files with 589 additions and 3,406 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ rebase the branch on main, fixing any conflicts along the way before the code ca
...
IngressGateway string = "ingressgateway"
```
1. Update `control-plane/subcommand/controller/command.go` and add your controller:
1. Update `control-plane/subcommand/inject-connect/command.go` and add your controller:
```go
if err = (&controller.IngressGatewayController{
ConfigEntryController: configEntryReconciler,
Expand All @@ -361,7 +361,7 @@ rebase the branch on main, fixing any conflicts along the way before the code ca
return 1
}
```
1. Update `control-plane/subcommand/controller/command.go` and add your webhook (the path should match the kubebuilder annotation):
1. Update `control-plane/subcommand/inject-connect/command.go` and add your webhook (the path should match the kubebuilder annotation):
```go
mgr.GetWebhookServer().Register("/mutate-v1alpha1-ingressgateway",
&webhook.Admission{Handler: &v1alpha1.IngressGatewayWebhook{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controller
package config_entries

import (
"fmt"
Expand Down Expand Up @@ -79,7 +79,6 @@ func TestControllerNamespaces(t *testing.T) {
helmValues := map[string]string{
"global.enableConsulNamespaces": "true",
"global.adminPartitions.enabled": "true",
"controller.enabled": "true",
"connectInject.enabled": "true",

// When mirroringK8S is set, this setting is ignored.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controller
package config_entries

import (
"fmt"
Expand Down Expand Up @@ -52,7 +52,6 @@ func TestController(t *testing.T) {
ctx := suite.Environment().DefaultContext(t)

helmValues := map[string]string{
"controller.enabled": "true",
"connectInject.enabled": "true",
"global.tls.enabled": strconv.FormatBool(c.secure),
"global.acls.manageSystemACLs": strconv.FormatBool(c.secure),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controller
package config_entries

import (
"os"
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/connect/connect_external_servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestConnectInject_ExternalServers(t *testing.T) {
"global.tls.enabled": strconv.FormatBool(secure),

// Don't install injector, controller and cni on this cluster so that it's not installed twice.
"controller.enabled": "false",
"connectInject.enabled": "false",
"connectInject.cni.enabled": "false",
}
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestComponentMetrics(t *testing.T) {
"client.enabled": "true",

"connectInject.enabled": "true",
"controller.enabled": "true",

"meshGateway.enabled": "true",
"meshGateway.replicas": "1",
Expand Down
2 changes: 0 additions & 2 deletions acceptance/tests/partitions/partitions_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ func TestPartitions_Connect(t *testing.T) {
"meshGateway.enabled": "true",
"meshGateway.replicas": "1",

"controller.enabled": "true",

"dns.enabled": "true",
"dns.enableRedirection": strconv.FormatBool(cfg.EnableTransparentProxy),
}
Expand Down
2 changes: 0 additions & 2 deletions acceptance/tests/peering/peering_connect_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ func TestPeering_ConnectNamespaces(t *testing.T) {
"meshGateway.enabled": "true",
"meshGateway.replicas": "1",

"controller.enabled": "true",

"dns.enabled": "true",
"dns.enableRedirection": strconv.FormatBool(cfg.EnableTransparentProxy),
}
Expand Down
2 changes: 0 additions & 2 deletions acceptance/tests/peering/peering_connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func TestPeering_Connect(t *testing.T) {
"meshGateway.enabled": "true",
"meshGateway.replicas": "1",

"controller.enabled": "true",

"dns.enabled": "true",
"dns.enableRedirection": strconv.FormatBool(cfg.EnableTransparentProxy),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestSnapshotAgent_K8sSecret(t *testing.T) {
"server.snapshotAgent.configSecret.secretName": saSecretName,
"server.snapshotAgent.configSecret.secretKey": saSecretKey,
"connectInject.enabled": "false",
"controller.enabled": "false",
}

// Get new cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func TestSnapshotAgent_Vault(t *testing.T) {

"connectInject.enabled": "false",
"connectInject.replicas": "1",
"controller.enabled": "false",

"global.secretsBackend.vault.enabled": "true",
"global.secretsBackend.vault.consulServerRole": consulServerRole,
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/vault/vault_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func TestVault_VaultNamespace(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",

"global.secretsBackend.vault.enabled": "true",
"global.secretsBackend.vault.consulServerRole": consulServerRole,
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/vault/vault_partitions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ func TestVault_Partitions(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",

"global.secretsBackend.vault.enabled": "true",
"global.secretsBackend.vault.consulClientRole": consulClientRole,
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func TestVault(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",
"global.secretsBackend.vault.connectInject.tlsCert.secretName": connectInjectorWebhookPKIConfig.CertPath,
"global.secretsBackend.vault.connectInject.caCert.secretName": connectInjectorWebhookPKIConfig.CAPath,
"global.secretsBackend.vault.controller.tlsCert.secretName": controllerWebhookPKIConfig.CertPath,
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/vault/vault_tls_auto_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func TestVault_TLSAutoReload(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",

"global.secretsBackend.vault.enabled": "true",
"global.secretsBackend.vault.consulServerRole": consulServerRole,
Expand Down
1 change: 0 additions & 1 deletion acceptance/tests/vault/vault_wan_fed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ func TestVault_WANFederationViaGateways(t *testing.T) {

// Mesh config.
"connectInject.enabled": "true",
"controller.enabled": "true",
"meshGateway.enabled": "true",
"meshGateway.replicas": "1",

Expand Down
2 changes: 0 additions & 2 deletions acceptance/tests/wan-federation/wan_federation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func TestWANFederation(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",

"meshGateway.enabled": "true",
"meshGateway.replicas": "1",
Expand Down Expand Up @@ -123,7 +122,6 @@ func TestWANFederation(t *testing.T) {

"connectInject.enabled": "true",
"connectInject.replicas": "1",
"controller.enabled": "true",

"meshGateway.enabled": "true",
"meshGateway.replicas": "1",
Expand Down
86 changes: 48 additions & 38 deletions charts/consul/templates/connect-inject-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,55 @@ metadata:
release: {{ .Release.Name }}
component: connect-injector
rules:
- apiGroups:
- consul.hashicorp.com
resources:
- servicedefaults
- serviceresolvers
- proxydefaults
- meshes
- exportedservices
- servicerouters
- servicesplitters
- serviceintentions
- ingressgateways
- terminatinggateways
{{- if .Values.global.peering.enabled }}
- peeringacceptors
- peeringdialers
{{- end }}
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- consul.hashicorp.com
resources:
- servicedefaults/status
- serviceresolvers/status
- proxydefaults/status
- meshes/status
- exportedservices/status
- servicerouters/status
- servicesplitters/status
- serviceintentions/status
- ingressgateways/status
- terminatinggateways/status
{{- if .Values.global.peering.enabled }}
- peeringacceptors/status
- peeringdialers/status
{{- end }}
verbs:
- get
- patch
- update
{{- if .Values.global.acls.manageSystemACLs }}
- apiGroups: [ "" ]
resources: ["serviceaccounts", "secrets"]
resources: [ "serviceaccounts", "secrets" ]
verbs:
- get
{{- end }}
Expand Down Expand Up @@ -53,50 +99,14 @@ rules:
{{- end }}
{{- if .Values.global.peering.enabled }}
- apiGroups: [ "" ]
resources: ["secrets"]
resources: [ "secrets" ]
verbs:
- "get"
- "list"
- "watch"
- "create"
- "update"
- "delete"
- apiGroups: ["consul.hashicorp.com"]
resources: ["peeringacceptors"]
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- consul.hashicorp.com
resources:
- peeringacceptors/status
verbs:
- get
- patch
- update
- apiGroups: ["consul.hashicorp.com"]
resources: ["peeringdialers"]
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- consul.hashicorp.com
resources:
- peeringdialers/status
verbs:
- get
- patch
- update
{{- end }}
{{- if .Values.global.enablePodSecurityPolicies }}
- apiGroups: [ "policy" ]
Expand Down
Loading

0 comments on commit 437eee1

Please sign in to comment.