Skip to content

Commit

Permalink
bug 1700903: standardize resource names
Browse files Browse the repository at this point in the history
  • Loading branch information
EvB committed Apr 23, 2019
1 parent b22c05a commit e451a71
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: openshift-authentication-operator
name: authentication-operator
namespace: openshift-authentication-operator
spec:
endpoints:
Expand All @@ -22,13 +22,13 @@ spec:
jobLabel: component
selector:
matchLabels:
app: openshift-authentication-operator
app: authentication-operator
---
# Configure cluster-monitoring for cluster authentication resources
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: openshift-authentication
name: integrated-oauth-server
namespace: openshift-authentication
spec:
endpoints:
Expand All @@ -44,8 +44,8 @@ spec:
scheme: https
tlsConfig:
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
serverName: openshift-authentication.openshift-authentication.svc
serverName: integrated-oauth-server.openshift-authentication.svc
jobLabel: component
selector:
matchLabels:
app: openshift-authentication
app: integrated-oauth-server
6 changes: 3 additions & 3 deletions manifests/02_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.openshift.io/serving-cert-secret-name: openshift-authentication-operator-serving-cert
service.alpha.openshift.io/serving-cert-secret-name: serving-cert
labels:
app: openshift-authentication-operator
app: authentication-operator
name: metrics
namespace: openshift-authentication-operator
spec:
Expand All @@ -15,6 +15,6 @@ spec:
protocol: TCP
targetPort: 8443
selector:
app: openshift-authentication-operator
app: authentication-operator
sessionAffinity: None
type: ClusterIP
2 changes: 1 addition & 1 deletion manifests/03_configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
namespace: openshift-authentication-operator
name: openshift-authentication-operator-config
name: authentication-operator-config
data:
operator-config.yaml: |
apiVersion: operator.openshift.io/v1alpha1
Expand Down
4 changes: 2 additions & 2 deletions manifests/04_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ roleRef:
subjects:
- kind: ServiceAccount
namespace: openshift-authentication-operator
name: openshift-authentication-operator
name: authentication-operator
- kind: ServiceAccount
namespace: openshift-authentication
name: openshift-authentication
name: integrated-oauth-server
8 changes: 4 additions & 4 deletions manifests/05_serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apiVersion: v1
kind: ServiceAccount
metadata:
namespace: openshift-authentication-operator
name: openshift-authentication-operator
name: authentication-operator
labels:
app: openshift-authentication-operator
app: authentication-operator
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: openshift-authentication
name: openshift-authentication
name: integrated-oauth-server
labels:
app: openshift-authentication
app: integrated-oauth-server
16 changes: 8 additions & 8 deletions manifests/06_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ apiVersion: apps/v1
kind: Deployment
metadata:
namespace: openshift-authentication-operator
name: openshift-authentication-operator
name: authentication-operator
labels:
app: openshift-authentication-operator
app: authentication-operator
spec:
replicas: 1
selector:
matchLabels:
app: openshift-authentication-operator
app: authentication-operator
template:
metadata:
name: openshift-authentication-operator
name: authentication-operator
labels:
app: openshift-authentication-operator
app: authentication-operator
spec:
serviceAccountName: openshift-authentication-operator
serviceAccountName: authentication-operator
containers:
- name: operator
image: quay.io/openshift/origin-cluster-authentication-operator:v4.0
Expand Down Expand Up @@ -50,10 +50,10 @@ spec:
- name: config
configMap:
defaultMode: 440
name: openshift-authentication-operator-config
name: authentication-operator-config
- name: serving-cert
secret:
secretName: openshift-authentication-operator-serving-cert
secretName: serving-cert
optional: true
nodeSelector:
node-role.kubernetes.io/master: ""
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator2/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const (
)

func (c *authOperator) handleServiceCA() (*corev1.ConfigMap, *corev1.Secret, error) {
cm := c.configMaps.ConfigMaps(targetName)
secret := c.secrets.Secrets(targetName)
cm := c.configMaps.ConfigMaps(targetNamespace)
secret := c.secrets.Secrets(targetNamespace)
serviceCA, err := cm.Get(serviceCAName, metav1.GetOptions{})
if errors.IsNotFound(err) {
serviceCA, err = cm.Create(defaultServiceCA())
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator2/configsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

func (c *authOperator) handleConfigSync(data *configSyncData) ([]string, error) {
// TODO we probably need listers
configMapClient := c.configMaps.ConfigMaps(targetName)
secretClient := c.secrets.Secrets(targetName)
configMapClient := c.configMaps.ConfigMaps(targetNamespace)
secretClient := c.secrets.Secrets(targetNamespace)

configMaps, err := configMapClient.List(metav1.ListOptions{})
if err != nil {
Expand Down Expand Up @@ -229,7 +229,7 @@ func syncOrDie(syncFunc func(dest, src resourcesynccontroller.ResourceLocation)
}
if err := syncFunc(
resourcesynccontroller.ResourceLocation{
Namespace: targetName,
Namespace: targetNamespace,
Name: dest,
},
resourcesynccontroller.ResourceLocation{
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator2/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func defaultDeployment(
SecurityContext: &corev1.PodSecurityContext{},
Containers: []corev1.Container{
{
Image: osinImage,
Image: oauthserverImage,
ImagePullPolicy: getImagePullPolicy(operatorDeployment),
Name: targetName,
Command: []string{
Expand Down
24 changes: 13 additions & 11 deletions pkg/operator2/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ import (
var deploymentVersionHashKey = operatorv1.GroupName + "/rvs-hash"

const (
clusterOperatorName = "authentication"
targetName = "openshift-authentication"
targetNameOperator = "openshift-authentication-operator"
globalConfigName = "cluster"
clusterOperatorName = "authentication"
targetName = "integrated-oauth-server"
targetNamespace = "openshift-authentication"
targetNameOperator = "authentication-operator"
targetNamespaceOperator = "openshift-authentication-operator"
globalConfigName = "cluster"

operatorSelfName = "operator"
osinOperandName = "integrated-oauth-server"
oauthserverOperandName = "integrated-oauth-server"
operatorVersionEnvName = "OPERATOR_IMAGE_VERSION"
operandVersionEnvName = "OPERAND_IMAGE_VERSION"
operandImageEnvName = "IMAGE"
Expand Down Expand Up @@ -119,8 +121,8 @@ const (

// static environment variables from operator deployment
var (
osinImage = os.Getenv(operandImageEnvName)
osinVersion = os.Getenv(operandVersionEnvName)
oauthserverImage = os.Getenv(operandImageEnvName)
oauthserverVersion = os.Getenv(operandVersionEnvName)

operatorVersion = os.Getenv(operatorVersionEnvName)

Expand Down Expand Up @@ -169,7 +171,7 @@ func NewAuthenticationOperator(
versionGetter: versionGetter,
recorder: recorder,

route: routeClient.Routes(targetName),
route: routeClient.Routes(targetNamespace),

oauthClientClient: oauthClientClient.OAuthClients(),

Expand Down Expand Up @@ -337,7 +339,7 @@ func (c *authOperator) handleSync(operatorConfig *operatorv1.Authentication) err
// BLOCK 4: deployment
// ==================================

operatorDeployment, err := c.deployments.Deployments(targetNameOperator).Get(targetNameOperator, metav1.GetOptions{})
operatorDeployment, err := c.deployments.Deployments(targetNamespaceOperator).Get(targetNameOperator, metav1.GetOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -427,7 +429,7 @@ func (c *authOperator) handleVersion(
setProgressingFalse(operatorConfig)
setAvailableTrue(operatorConfig, "AsExpected")
c.setVersion(operatorSelfName, operatorVersion)
c.setVersion(osinOperandName, osinVersion)
c.setVersion(oauthserverOperandName, oauthserverVersion)

return nil
}
Expand Down Expand Up @@ -571,7 +573,7 @@ func defaultLabels() map[string]string {
func defaultMeta() metav1.ObjectMeta {
return metav1.ObjectMeta{
Name: targetName,
Namespace: targetName,
Namespace: targetNamespace,
Labels: defaultLabels(),
Annotations: map[string]string{},
OwnerReferences: nil, // TODO
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator2/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *authOperator) handleRoute() (*routev1.Route, *corev1.Secret, error) {
return nil, nil, err
}

routerSecret, err := c.secrets.Secrets(targetName).Get(routerCertsLocalName, metav1.GetOptions{})
routerSecret, err := c.secrets.Secrets(targetNamespace).Get(routerCertsLocalName, metav1.GetOptions{})
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator2/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func (c *authOperator) expectedSessionSecret() (*corev1.Secret, error) {
secret, err := c.secrets.Secrets(targetName).Get(sessionNameAndKey, metav1.GetOptions{})
secret, err := c.secrets.Secrets(targetNamespace).Get(sessionNameAndKey, metav1.GetOptions{})
if err != nil || !isValidSessionSecret(secret) {
klog.V(4).Infof("failed to get secret %s: %v", sessionNameAndKey, err)
generatedSessionSecret, err := randomSessionSecret()
Expand Down
12 changes: 6 additions & 6 deletions pkg/operator2/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
}

kubeInformersNamespaced := informers.NewSharedInformerFactoryWithOptions(kubeClient, resync,
informers.WithNamespace(targetName),
informers.WithNamespace(targetNamespace),
)

authOperatorConfigInformers := authopinformer.NewSharedInformerFactoryWithOptions(authConfigClient, resync,
authopinformer.WithTweakListOptions(singleNameListOptions(globalConfigName)),
)

routeInformersNamespaced := routeinformer.NewSharedInformerFactoryWithOptions(routeClient, resync,
routeinformer.WithNamespace(targetName),
routeinformer.WithNamespace(targetNamespace),
routeinformer.WithTweakListOptions(singleNameListOptions(targetName)),
)

Expand All @@ -101,7 +101,7 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {

resourceSyncerInformers := v1helpers.NewKubeInformersForNamespaces(
kubeClient,
targetName,
targetNamespace,
userConfigNamespace,
machineConfigNamespace,
)
Expand All @@ -122,14 +122,14 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
// add syncing for the OAuth metadata ConfigMap
if err := resourceSyncer.SyncConfigMap(
resourcesynccontroller.ResourceLocation{Namespace: machineConfigNamespace, Name: targetName},
resourcesynccontroller.ResourceLocation{Namespace: targetName, Name: oauthMetadataName},
resourcesynccontroller.ResourceLocation{Namespace: targetNamespace, Name: oauthMetadataName},
); err != nil {
return err
}

// add syncing for router certs for all cluster ingresses
if err := resourceSyncer.SyncSecret(
resourcesynccontroller.ResourceLocation{Namespace: targetName, Name: routerCertsLocalName},
resourcesynccontroller.ResourceLocation{Namespace: targetNamespace, Name: routerCertsLocalName},
resourcesynccontroller.ResourceLocation{Namespace: machineConfigNamespace, Name: routerCertsSharedName},
); err != nil {
return err
Expand Down Expand Up @@ -160,7 +160,7 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
{Group: configv1.GroupName, Resource: "oauths", Name: globalConfigName},
{Resource: "namespaces", Name: userConfigNamespace},
{Resource: "namespaces", Name: machineConfigNamespace},
{Resource: "namespaces", Name: targetName},
{Resource: "namespaces", Name: targetNamespace},
{Resource: "namespaces", Name: targetNameOperator},
},
configClient.ConfigV1(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func Get() version.Info {
func init() {
buildInfo := prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "openshift_cluster_osin_operator_build_info",
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which OpenShift Osin Operator was built.",
Name: "openshift_cluster_authentication_operator_build_info",
Help: "A metric with a constant '1' value labeled by major, minor, git commit & git version from which OpenShift Authentication Operator was built.",
},
[]string{"major", "minor", "gitCommit", "gitVersion"},
)
Expand Down

0 comments on commit e451a71

Please sign in to comment.