diff --git a/pkg/kustomize/transformers/namereferenceconfig.go b/pkg/kustomize/transformers/namereferenceconfig.go index 3e1ff44b..022b83aa 100644 --- a/pkg/kustomize/transformers/namereferenceconfig.go +++ b/pkg/kustomize/transformers/namereferenceconfig.go @@ -339,4 +339,134 @@ var defaultNameReferencePathConfigs = []referencePathConfig{ }, }, }, + { + // StatefulSet references headless service, so need to update the references. + referencedGVK: schema.GroupVersionKind{ + Version: "v1", + Kind: "Service", + }, + pathConfigs: []PathConfig{ + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "apps", + Kind: "StatefulSet", + }, + Path: []string{"spec", "serviceName"}, + CreateIfNotPresent: false, + }, + }, + }, + { + referencedGVK: schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "Role", + }, + pathConfigs: []PathConfig{ + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "RoleBinding", + }, + Path: []string{"roleRef", "name"}, + CreateIfNotPresent: false, + }, + }, + }, + { + referencedGVK: schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "ClusterRole", + }, + pathConfigs: []PathConfig{ + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "RoleBinding", + }, + Path: []string{"roleRef", "name"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "ClusterRoleBinding", + }, + Path: []string{"roleRef", "name"}, + CreateIfNotPresent: false, + }, + }, + }, + { + referencedGVK: schema.GroupVersionKind{ + Version: "v1", + Kind: "ServiceAccount", + }, + pathConfigs: []PathConfig{ + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "RoleBinding", + }, + Path: []string{"subjects", "name"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Group: "rbac.authorization.k8s.io", + Kind: "ClusterRoleBinding", + }, + Path: []string{"subjects", "name"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "Pod", + }, + Path: []string{"spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "StatefulSet", + }, + Path: []string{"spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "Deployment", + }, + Path: []string{"spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "ReplicationController", + }, + Path: []string{"spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "CronJob", + }, + Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "Job", + }, + Path: []string{"spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + { + GroupVersionKind: &schema.GroupVersionKind{ + Kind: "DaemonSet", + }, + Path: []string{"spec", "template", "spec", "serviceAccountName"}, + CreateIfNotPresent: false, + }, + }, + }, }