Skip to content

Commit

Permalink
refactor: Rename *Resources.*StatefulSetName and deploymentName metho…
Browse files Browse the repository at this point in the history
…ds (#9520)

Signed-off-by: Anefu <einsteinanefu@gmail.com>
  • Loading branch information
Anefu committed Jan 9, 2024
1 parent ba4180e commit bbda1f7
Show file tree
Hide file tree
Showing 91 changed files with 442 additions and 442 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private KafkaBridgeResources() { }
* @param clusterName The {@code metadata.name} of the {@code KafkaBridge} resource.
* @return The name of the corresponding Kafka Bridge {@code Deployment}.
*/
public static String deploymentName(String clusterName) {
public static String componentName(String clusterName) {
return clusterName + "-bridge";
}

Expand Down Expand Up @@ -45,7 +45,7 @@ public static String metricsAndLogConfigMapName(String clusterName) {
* @return The name of the corresponding Kafka Bridge {@code ServiceAccount}.
*/
public static String serviceAccountName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand All @@ -68,6 +68,6 @@ public static String url(String clusterName, String namespace, int port) {
* @return The name of the init container's cluster role binding.
*/
public static String initContainerClusterRoleBindingName(String clusterName, String namespace) {
return "strimzi-" + namespace + "-" + deploymentName(clusterName) + "-init";
return "strimzi-" + namespace + "-" + componentName(clusterName) + "-init";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected KafkaConnectResources() { }
* @param clusterName The {@code metadata.name} of the {@code KafkaConnect} resource.
* @return The name of the corresponding Kafka Connect {@code Deployment}.
*/
public static String deploymentName(String clusterName) {
public static String componentName(String clusterName) {
return clusterName + "-connect";
}

Expand All @@ -26,7 +26,7 @@ public static String deploymentName(String clusterName) {
* @return The name of the corresponding Kafka Connect {@code ServiceAccount}.
*/
public static String serviceAccountName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public static String jmxSecretName(String clusterName) {
* @return The name of the corresponding KafkaConnect metrics and log {@code ConfigMap}.
*/
public static String metricsAndLogConfigMapName(String clusterName) {
return deploymentName(clusterName) + "-config";
return componentName(clusterName) + "-config";
}

/**
Expand All @@ -67,7 +67,7 @@ public static String metricsAndLogConfigMapName(String clusterName) {
* @return The name of the corresponding KafkaConnect config offsets value.
*/
public static String configStorageTopicOffsets(String clusterName) {
return deploymentName(clusterName) + "-offsets";
return componentName(clusterName) + "-offsets";
}

/**
Expand All @@ -76,7 +76,7 @@ public static String configStorageTopicOffsets(String clusterName) {
* @return The name of the corresponding KafkaConnect config status value.
*/
public static String configStorageTopicStatus(String clusterName) {
return deploymentName(clusterName) + "-status";
return componentName(clusterName) + "-status";
}

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public static String url(String clusterName, String namespace, int port) {
* @return The name of the init container's cluster role binding.
*/
public static String initContainerClusterRoleBindingName(String clusterName, String namespace) {
return "strimzi-" + namespace + "-" + deploymentName(clusterName) + "-init";
return "strimzi-" + namespace + "-" + componentName(clusterName) + "-init";
}

/**
Expand All @@ -119,7 +119,7 @@ public static String initContainerClusterRoleBindingName(String clusterName, Str
* @return The name of the corresponding Kafka Connect {@code ConfigMap}.
*/
public static String dockerFileConfigMapName(String clusterName) {
return deploymentName(clusterName) + "-dockerfile";
return componentName(clusterName) + "-dockerfile";
}

/**
Expand All @@ -129,7 +129,7 @@ public static String dockerFileConfigMapName(String clusterName) {
* @return The name of the corresponding Kafka Connect build {@code Pod}.
*/
public static String buildPodName(String clusterName) {
return deploymentName(clusterName) + "-build";
return componentName(clusterName) + "-build";
}

/**
Expand All @@ -140,7 +140,7 @@ public static String buildPodName(String clusterName) {
* @return The name of the corresponding Kafka Connect Build {@code ServiceAccount}.
*/
public static String buildServiceAccountName(String clusterName) {
return deploymentName(clusterName) + "-build";
return componentName(clusterName) + "-build";
}

/**
Expand All @@ -150,7 +150,7 @@ public static String buildServiceAccountName(String clusterName) {
* @return The name of the corresponding Kafka Connect {@code BuildConfig}.
*/
public static String buildConfigName(String clusterName) {
return deploymentName(clusterName) + "-build";
return componentName(clusterName) + "-build";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected JmxTransResources() { }
* @param kafkaClusterName The {@code metadata.name} of the {@code Kafka} resource.
* @return The name of the corresponding JmxTrans {@code Deployment}.
*/
public static String deploymentName(String kafkaClusterName) {
public static String componentName(String kafkaClusterName) {
return kafkaClusterName + "-kafka-jmx-trans";
}

Expand All @@ -25,7 +25,7 @@ public static String deploymentName(String kafkaClusterName) {
* @return The name of the corresponding JmxTrans {@code ServiceAccount}.
*/
public static String serviceAccountName(String kafkaClusterName) {
return deploymentName(kafkaClusterName);
return componentName(kafkaClusterName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static String clientsCaKeySecretName(String clusterName) {
* @param clusterName The {@code metadata.name} of the {@code Kafka} resource.
* @return The name of the corresponding Kafka {@code StrimziPodSet}.
*/
public static String kafkaStatefulSetName(String clusterName) {
public static String kafkaComponentName(String clusterName) {
return clusterName + "-kafka";
}

Expand All @@ -67,7 +67,7 @@ public static String kafkaStatefulSetName(String clusterName) {
* @return The name of the corresponding Kafka {@code Pod}.
*/
public static String kafkaPodName(String clusterName, int podNum) {
return kafkaStatefulSetName(clusterName) + "-" + podNum;
return kafkaComponentName(clusterName) + "-" + podNum;
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ public static String kafkaNetworkPolicyName(String clusterName) {
* @param clusterName The {@code metadata.name} of the {@code Kafka} resource.
* @return The name of the corresponding ZooKeeper {@code StrimziPodSet}.
*/
public static String zookeeperStatefulSetName(String clusterName) {
public static String zookeeperComponentName(String clusterName) {
return clusterName + "-zookeeper";
}

Expand All @@ -207,7 +207,7 @@ public static String zookeeperStatefulSetName(String clusterName) {
* @return The name of the corresponding ZooKeeper {@code Pod}.
*/
public static String zookeeperPodName(String clusterName, int podNum) {
return zookeeperStatefulSetName(clusterName) + "-" + podNum;
return zookeeperComponentName(clusterName) + "-" + podNum;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CruiseControlResources {
* @param clusterName The {@code metadata.name} of the {@code Kafka} resource.
* @return The name of the corresponding Cruise Control {@code Deployment}.
*/
public static String deploymentName(String clusterName) {
public static String componentName(String clusterName) {
return clusterName + "-cruise-control";
}

Expand All @@ -25,7 +25,7 @@ public static String deploymentName(String clusterName) {
* @return The name of the corresponding Cruise Control {@code ServiceAccount}.
*/
public static String serviceAccountName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand All @@ -34,7 +34,7 @@ public static String serviceAccountName(String clusterName) {
* @return The name of the corresponding Cruise Control {@code Service}.
*/
public static String serviceName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand All @@ -57,7 +57,7 @@ public static String qualifiedServiceName(String clusterName, String namespace)
* @return The name of the corresponding Cruise Control {@code Secret}.
*/
public static String apiSecretName(String clusterName) {
return deploymentName(clusterName) + "-api";
return componentName(clusterName) + "-api";
}

/**
Expand All @@ -69,7 +69,7 @@ public static String apiSecretName(String clusterName) {
* @return The name of the corresponding Cruise Control {@code Secret}.
*/
public static String secretName(String clusterName) {
return deploymentName(clusterName) + "-certs";
return componentName(clusterName) + "-certs";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected KafkaExporterResources() { }
* @param kafkaClusterName The {@code metadata.name} of the {@code Kafka} resource.
* @return The name of the corresponding Kafka Exporter {@code Deployment}.
*/
public static String deploymentName(String kafkaClusterName) {
public static String componentName(String kafkaClusterName) {
return kafkaClusterName + "-kafka-exporter";
}

Expand All @@ -26,7 +26,7 @@ public static String deploymentName(String kafkaClusterName) {
* @return The name of the corresponding Kafka Exporter {@code ServiceAccount}.
*/
public static String serviceAccountName(String kafkaClusterName) {
return deploymentName(kafkaClusterName);
return componentName(kafkaClusterName);
}

/**
Expand All @@ -47,6 +47,6 @@ public static String serviceName(String kafkaClusterName) {
* @return The name of the corresponding Kafka Exporter {@code Secret}.
*/
public static String secretName(String clusterName) {
return deploymentName(clusterName) + "-certs";
return componentName(clusterName) + "-certs";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected KafkaMirrorMakerResources() { }
* @param clusterName The {@code metadata.name} of the {@code KafkaMirrorMaker} resource.
* @return The name of the corresponding Kafka MirrorMaker {@code Deployment}.
*/
public static String deploymentName(String clusterName) {
public static String componentName(String clusterName) {
return clusterName + "-mirror-maker";
}

Expand All @@ -26,7 +26,7 @@ public static String deploymentName(String clusterName) {
* @return The name of the corresponding Kafka MirrorMaker {@code ServiceAccount}.
*/
public static String serviceAccountName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class KafkaMirrorMaker2Resources {
* @param clusterName The {@code metadata.name} of the {@code KafkaMirrorMaker2} resource.
* @return The name of the corresponding Kafka MirrorMaker 2 {@code Deployment}.
*/
public static String deploymentName(String clusterName) {
public static String componentName(String clusterName) {
return clusterName + "-mirrormaker2";
}

Expand All @@ -25,7 +25,7 @@ public static String deploymentName(String clusterName) {
* @return The name of the corresponding Kafka MirrorMaker 2 {@code ServiceAccount}.
*/
public static String serviceAccountName(String clusterName) {
return deploymentName(clusterName);
return componentName(clusterName);
}

/**
Expand Down Expand Up @@ -77,6 +77,6 @@ public static String url(String clusterName, String namespace, int port) {
* @return The name of the init container's cluster role binding.
*/
public static String initContainerClusterRoleBindingName(String clusterName, String namespace) {
return "strimzi-" + namespace + "-" + deploymentName(clusterName) + "-init";
return "strimzi-" + namespace + "-" + componentName(clusterName) + "-init";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected Map<String, CertAndKey> generateZkCerts(
Function<NodeRef, Subject> subjectFn = node -> {
Subject.Builder subject = new Subject.Builder()
.withOrganizationName("io.strimzi")
.withCommonName(KafkaResources.zookeeperStatefulSetName(crName));
.withCommonName(KafkaResources.zookeeperComponentName(crName));
subject.addDnsName(KafkaResources.zookeeperServiceName(crName));
subject.addDnsName(String.format("%s.%s", KafkaResources.zookeeperServiceName(crName), namespace));
subject.addDnsName(zkDnsGenerator.serviceDnsNameWithoutClusterDomain());
Expand Down Expand Up @@ -222,7 +222,7 @@ protected Map<String, CertAndKey> generateBrokerCerts(
Function<NodeRef, Subject> subjectFn = node -> {
Subject.Builder subject = new Subject.Builder()
.withOrganizationName("io.strimzi")
.withCommonName(KafkaResources.kafkaStatefulSetName(crName));
.withCommonName(KafkaResources.kafkaComponentName(crName));

subject.addDnsNames(ModelUtils.generateAllServiceDnsNames(namespace, KafkaResources.bootstrapServiceName(crName)));
subject.addDnsNames(ModelUtils.generateAllServiceDnsNames(namespace, KafkaResources.brokersServiceName(crName)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public class CruiseControl extends AbstractModel implements SupportsMetrics, Sup
* @param sharedEnvironmentProvider Shared environment provider
*/
private CruiseControl(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
super(reconciliation, resource, CruiseControlResources.deploymentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
super(reconciliation, resource, CruiseControlResources.componentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public class KafkaBridgeCluster extends AbstractModel implements SupportsLogging
* @param sharedEnvironmentProvider Shared environment provider
*/
private KafkaBridgeCluster(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
super(reconciliation, resource, KafkaBridgeResources.deploymentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
super(reconciliation, resource, KafkaBridgeResources.componentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public KafkaBrokerConfigurationBuilder withAuthorization(String clusterName, Kaf
List<String> superUsers = new ArrayList<>();

// Broker super users
superUsers.add(String.format("User:CN=%s,O=io.strimzi", KafkaResources.kafkaStatefulSetName(clusterName)));
superUsers.add(String.format("User:CN=%s,O=io.strimzi", KafkaResources.kafkaComponentName(clusterName)));
superUsers.add(String.format("User:CN=%s-%s,O=io.strimzi", clusterName, "entity-topic-operator"));
superUsers.add(String.format("User:CN=%s-%s,O=io.strimzi", clusterName, "entity-user-operator"));
superUsers.add(String.format("User:CN=%s-%s,O=io.strimzi", clusterName, "kafka-exporter"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public class KafkaCluster extends AbstractModel implements SupportsMetrics, Supp
* @param sharedEnvironmentProvider Shared environment provider
*/
private KafkaCluster(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
super(reconciliation, resource, KafkaResources.kafkaStatefulSetName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
super(reconciliation, resource, KafkaResources.kafkaComponentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);

this.initImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_INIT_IMAGE, "quay.io/strimzi/operator:latest");
}
Expand Down Expand Up @@ -1517,8 +1517,8 @@ public NetworkPolicy generateNetworkPolicy(String operatorNamespace, Labels oper
NetworkPolicyPeer clusterOperatorPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_KIND_LABEL, "cluster-operator"), NetworkPolicyUtils.clusterOperatorNamespaceSelector(namespace, operatorNamespace, operatorNamespaceLabels));
NetworkPolicyPeer kafkaClusterPeer = NetworkPolicyUtils.createPeer(labels.strimziSelectorLabels().toMap());
NetworkPolicyPeer entityOperatorPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_NAME_LABEL, KafkaResources.entityOperatorDeploymentName(cluster)));
NetworkPolicyPeer kafkaExporterPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_NAME_LABEL, KafkaExporterResources.deploymentName(cluster)));
NetworkPolicyPeer cruiseControlPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_NAME_LABEL, CruiseControlResources.deploymentName(cluster)));
NetworkPolicyPeer kafkaExporterPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_NAME_LABEL, KafkaExporterResources.componentName(cluster)));
NetworkPolicyPeer cruiseControlPeer = NetworkPolicyUtils.createPeer(Map.of(Labels.STRIMZI_NAME_LABEL, CruiseControlResources.componentName(cluster)));

// List of network policy rules for all ports
List<NetworkPolicyIngressRule> rules = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public class KafkaConnectCluster extends AbstractModel implements SupportsMetric
* @param sharedEnvironmentProvider Shared environment provider
*/
protected KafkaConnectCluster(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
this(reconciliation, resource, KafkaConnectResources.deploymentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
this(reconciliation, resource, KafkaConnectResources.componentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class KafkaExporter extends AbstractModel {
* @param sharedEnvironmentProvider Shared environment provider
*/
protected KafkaExporter(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
super(reconciliation, resource, KafkaExporterResources.deploymentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
super(reconciliation, resource, KafkaExporterResources.componentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);

this.saramaLoggingEnabled = false;
this.showAllOffsets = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class KafkaMirrorMaker2Cluster extends KafkaConnectCluster {
* @param sharedEnvironmentProvider Shared environment provider
*/
private KafkaMirrorMaker2Cluster(Reconciliation reconciliation, HasMetadata resource, SharedEnvironmentProvider sharedEnvironmentProvider) {
super(reconciliation, resource, KafkaMirrorMaker2Resources.deploymentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);
super(reconciliation, resource, KafkaMirrorMaker2Resources.componentName(resource.getMetadata().getName()), COMPONENT_TYPE, sharedEnvironmentProvider);

this.serviceName = KafkaMirrorMaker2Resources.serviceName(cluster);
this.loggingAndMetricsConfigMapName = KafkaMirrorMaker2Resources.metricsAndLogConfigMapName(cluster);
Expand Down

0 comments on commit bbda1f7

Please sign in to comment.