Skip to content

Commit

Permalink
Standardize resource names across the helm chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Venkatesh committed Jan 25, 2022
1 parent 181707e commit cc59742
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-role
name: {{ template "consul.fullname" . }}-connect-injector-authmethod
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-authdelegator-role-binding
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-authdelegator
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand All @@ -16,13 +16,13 @@ roleRef:
name: "system:auth-delegator"
subjects:
- kind: ServiceAccount
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-svc-account
name: {{ template "consul.fullname" . }}-connect-injector-authmethod
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-serviceaccount-role-binding
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-serviceaccount
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand All @@ -31,10 +31,10 @@ metadata:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-role
name: {{ template "consul.fullname" . }}-connect-injector-authmethod
subjects:
- kind: ServiceAccount
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-svc-account
name: {{ template "consul.fullname" . }}-connect-injector-authmethod
namespace: {{ .Release.Namespace }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-authmethod-svc-account
name: {{ template "consul.fullname" . }}-connect-injector-authmethod
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
4 changes: 2 additions & 2 deletions charts/consul/templates/connect-inject-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-webhook
name: {{ template "consul.fullname" . }}-connect-injector
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand All @@ -30,7 +30,7 @@ rules:
- apiGroups: ["policy"]
resources: ["podsecuritypolicies"]
resourceNames:
- {{ template "consul.fullname" . }}-connect-injector-webhook
- {{ template "consul.fullname" . }}-connect-injector
verbs:
- use
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-webhook-admin-role-binding
name: {{ template "consul.fullname" . }}-connect-injector
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
Expand All @@ -12,9 +12,9 @@ metadata:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "consul.fullname" . }}-connect-injector-webhook
name: {{ template "consul.fullname" . }}-connect-injector
subjects:
- kind: ServiceAccount
name: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/consul/templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-webhook-deployment
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down Expand Up @@ -50,7 +50,7 @@ spec:
{{- end }}
{{- end }}
spec:
serviceAccountName: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
serviceAccountName: {{ template "consul.fullname" . }}-connect-injector
containers:
- name: sidecar-injector
image: "{{ default .Values.global.imageK8S .Values.connectInject.image }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ roleRef:
name: {{ template "consul.fullname" . }}-connect-inject-leader-election
subjects:
- kind: ServiceAccount
name: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-cfg
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand All @@ -26,7 +26,7 @@ webhooks:
- "v1"
clientConfig:
service:
name: {{ template "consul.fullname" . }}-connect-injector-svc
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
path: "/mutate"
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-webhook
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/connect-inject-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-svc
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/connect-inject-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
name: {{ template "consul.fullname" . }}-connect-injector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: {{ template "consul.fullname" . }}-controller-mutating-webhook-configuration
name: {{ template "consul.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/partition-init-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rules:
resources:
- serviceaccounts
resourceNames:
- {{ template "consul.fullname" . }}-connect-injector-authmethod-svc-account
- {{ template "consul.fullname" . }}-connect-injector-authmethod
verbs:
- get
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/partition-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "consul.fullname" . }}-partition-service
name: {{ template "consul.fullname" . }}-partition
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/server-acl-init-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rules:
resources:
- serviceaccounts
resourceNames:
- {{ template "consul.fullname" . }}-connect-injector-authmethod-svc-account
- {{ template "consul.fullname" . }}-connect-injector-authmethod
verbs:
- get
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/ui-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apiVersion: networking.k8s.io/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ template "consul.fullname" . }}-ingress
name: {{ template "consul.fullname" . }}-ui
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rules:
resources:
- podsecuritypolicies
resourceNames:
- {{ template "consul.fullname" . }}-connect-injector-webhook
- {{ template "consul.fullname" . }}-connect-injector
verbs:
- use
{{- end }}
Expand Down
12 changes: 6 additions & 6 deletions charts/consul/templates/webhook-cert-manager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ data:
[
{{- if .Values.connectInject.enabled }}
{
"name": "{{ template "consul.fullname" . }}-connect-injector-cfg",
"name": "{{ template "consul.fullname" . }}-connect-injector",
"tlsAutoHosts": [
"{{ template "consul.fullname" . }}-connect-injector-svc",
"{{ template "consul.fullname" . }}-connect-injector-svc.{{ .Release.Namespace }}",
"{{ template "consul.fullname" . }}-connect-injector-svc.{{ .Release.Namespace }}.svc",
"{{ template "consul.fullname" . }}-connect-injector-svc.{{ .Release.Namespace }}.svc.cluster.local"
"{{ template "consul.fullname" . }}-connect-injector",
"{{ template "consul.fullname" . }}-connect-injector.{{ .Release.Namespace }}",
"{{ template "consul.fullname" . }}-connect-injector.{{ .Release.Namespace }}.svc",
"{{ template "consul.fullname" . }}-connect-injector.{{ .Release.Namespace }}.svc.cluster.local"
],
"secretName": "{{ template "consul.fullname" . }}-connect-inject-webhook-cert",
"secretNamespace": "{{ .Release.Namespace }}"
}{{- if and .Values.controller.enabled }},{{- end }}{{- end }}
{{- if and .Values.controller.enabled }}
{
"name": "{{ template "consul.fullname" . }}-controller-mutating-webhook-configuration",
"name": "{{ template "consul.fullname" . }}-controller",
"tlsAutoHosts": [
"{{ template "consul.fullname" . }}-controller-webhook",
"{{ template "consul.fullname" . }}-controller-webhook.{{ .Release.Namespace }}",
Expand Down
8 changes: 4 additions & 4 deletions charts/consul/test/unit/webhook-cert-manager-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ load _helpers
local actual=$(echo $cfg | jq '. | length == 1')
[ "${actual}" = "true" ]

local actual=$(echo $cfg | jq '.[0].name | contains("controller-mutating-webhook-configuration")')
local actual=$(echo $cfg | jq '.[0].name | contains("controller")')
[ "${actual}" = "true" ]
}

Expand All @@ -68,7 +68,7 @@ load _helpers
local actual=$(echo $cfg | jq '. | length == 1')
[ "${actual}" = "true" ]

local actual=$(echo $cfg | jq '.[0].name | contains("controller-mutating-webhook-configuration")')
local actual=$(echo $cfg | jq '.[0].name | contains("controller")')
[ "${actual}" = "false" ]
}

Expand All @@ -85,9 +85,9 @@ load _helpers
local actual=$(echo $cfg | jq '. | length == 2')
[ "${actual}" = "true" ]

local actual=$(echo $cfg | jq '.[0].name | contains("connect-injector-cfg")')
local actual=$(echo $cfg | jq '.[0].name | contains("connect-injector")')
[ "${actual}" = "true" ]

local actual=$(echo $cfg | jq '.[1].name | contains("controller-mutating-webhook-configuration")')
local actual=$(echo $cfg | jq '.[1].name | contains("controller")')
[ "${actual}" = "true" ]
}
6 changes: 3 additions & 3 deletions control-plane/subcommand/server-acl-init/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ func getBootToken(t *testing.T, k8s *fake.Clientset, prefix string, k8sNamespace
func setUpK8sServiceAccount(t *testing.T, k8s *fake.Clientset, namespace string) (string, string) {
// Create ServiceAccount for the kubernetes auth method if it doesn't exist,
// otherwise, do nothing.
serviceAccountName := resourcePrefix + "-connect-injector-authmethod-svc-account"
serviceAccountName := resourcePrefix + "-connect-injector-authmethod"
sa, _ := k8s.CoreV1().ServiceAccounts(namespace).Get(context.Background(), serviceAccountName, metav1.GetOptions{})
if sa == nil {
// Create a service account that references two secrets.
Expand All @@ -2282,7 +2282,7 @@ func setUpK8sServiceAccount(t *testing.T, k8s *fake.Clientset, namespace string)
Name: resourcePrefix + "-some-other-secret",
},
{
Name: resourcePrefix + "-connect-injector-authmethod-svc-account",
Name: resourcePrefix + "-connect-injector-authmethod",
},
},
},
Expand All @@ -2297,7 +2297,7 @@ func setUpK8sServiceAccount(t *testing.T, k8s *fake.Clientset, namespace string)
require.NoError(t, err)

// Create a Kubernetes secret if it doesn't exist, otherwise update it
secretName := resourcePrefix + "-connect-injector-authmethod-svc-account"
secretName := resourcePrefix + "-connect-injector-authmethod"
secret := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Expand Down
2 changes: 1 addition & 1 deletion control-plane/subcommand/server-acl-init/connect_inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *Command) configureConnectInjectAuthMethod(consulClient *api.Client) err
func (c *Command) createAuthMethodTmpl(authMethodName string) (api.ACLAuthMethod, error) {
// Get the Secret name for the auth method ServiceAccount.
var authMethodServiceAccount *apiv1.ServiceAccount
saName := c.withPrefix("connect-injector-authmethod-svc-account")
saName := c.withPrefix("connect-injector-authmethod")
err := c.untilSucceeds(fmt.Sprintf("getting %s ServiceAccount", saName),
func() error {
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func TestCommand_createAuthMethodTmpl_SecretNotFound(t *testing.T) {
ctx: ctx,
}

serviceAccountName := resourcePrefix + "-connect-injector-authmethod-svc-account"
secretName := resourcePrefix + "-connect-injector-authmethod-svc-account"
serviceAccountName := resourcePrefix + "-connect-injector-authmethod"
secretName := resourcePrefix + "-connect-injector-authmethod"

// Create a service account referencing secretName
sa, _ := k8s.CoreV1().ServiceAccounts(ns).Get(ctx, serviceAccountName, metav1.GetOptions{})
Expand Down Expand Up @@ -65,5 +65,5 @@ func TestCommand_createAuthMethodTmpl_SecretNotFound(t *testing.T) {
require.NoError(t, err)

_, err = cmd.createAuthMethodTmpl("test")
require.EqualError(t, err, "found no secret of type 'kubernetes.io/service-account-token' associated with the release-name-consul-connect-injector-authmethod-svc-account service account")
require.EqualError(t, err, "found no secret of type 'kubernetes.io/service-account-token' associated with the release-name-consul-connect-injector-authmethod service account")
}

0 comments on commit cc59742

Please sign in to comment.