use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniRole method createRoleBinding.
/**
* Create the RoleBinding for patroni associated to the cluster.
*/
private RoleBinding createRoleBinding(StackGresDistributedLogsContext context) {
final StackGresDistributedLogs cluster = context.getSource();
final Map<String, String> labels = labelFactory.clusterLabels(cluster);
return new RoleBindingBuilder().withNewMetadata().withName(roleName(context)).withNamespace(cluster.getMetadata().getNamespace()).withLabels(labels).endMetadata().withSubjects(new SubjectBuilder().withKind("ServiceAccount").withName(roleName(context)).withNamespace(cluster.getMetadata().getNamespace()).build()).withRoleRef(new RoleRefBuilder().withKind("Role").withName(roleName(context)).withApiGroup("rbac.authorization.k8s.io").build()).build();
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniServices method configName.
public String configName(StackGresDistributedLogsContext clusterContext) {
final StackGresDistributedLogs cluster = clusterContext.getSource();
final String scope = labelFactory.clusterScope(cluster);
return ResourceUtil.resourceName(scope + PatroniUtil.CONFIG_SERVICE);
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniTemplatesConfigMap method buildSource.
@NotNull
public HasMetadata buildSource(StackGresDistributedLogsContext context) {
Map<String, String> data = getPatroniTemplates();
final StackGresDistributedLogs cluster = context.getSource();
return new ConfigMapBuilder().withNewMetadata().withNamespace(cluster.getMetadata().getNamespace()).withName(name(cluster)).withLabels(labelFactory.clusterLabels(cluster)).endMetadata().withData(data).build();
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniContainer method getContainer.
@Override
public Container getContainer(DistributedLogsContainerContext context) {
final StackGresDistributedLogs distributedLogs = context.getDistributedLogsContext().getSource();
final String startScript = "/start-patroni.sh";
return new ContainerBuilder().withName(StackgresClusterContainers.PATRONI).withImage(IMAGE_NAME).withCommand("/bin/sh", "-ex", ClusterStatefulSetPath.LOCAL_BIN_PATH.path() + startScript).withImagePullPolicy("IfNotPresent").withVolumeMounts(getVolumeMounts(context)).withEnvFrom(new EnvFromSourceBuilder().withConfigMapRef(new ConfigMapEnvSourceBuilder().withName(distributedLogs.getMetadata().getName()).build()).build()).withEnv(getEnvVars(context)).withPorts(new ContainerPortBuilder().withProtocol("TCP").withName(PatroniConfigMap.POSTGRES_PORT_NAME).withContainerPort(EnvoyUtil.PG_PORT).build(), new ContainerPortBuilder().withProtocol("TCP").withName(PatroniConfigMap.POSTGRES_REPLICATION_PORT_NAME).withContainerPort(EnvoyUtil.PG_REPL_ENTRY_PORT).build(), new ContainerPortBuilder().withName(PATRONI_RESTAPI_PORT_NAME).withProtocol("TCP").withContainerPort(EnvoyUtil.PATRONI_ENTRY_PORT).build()).withLivenessProbe(new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/cluster").withPort(new IntOrString(EnvoyUtil.PATRONI_ENTRY_PORT)).withScheme("HTTP").build()).withInitialDelaySeconds(15).withPeriodSeconds(20).withFailureThreshold(6).build()).withReadinessProbe(new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/read-only").withPort(new IntOrString(EnvoyUtil.PATRONI_ENTRY_PORT)).withScheme("HTTP").build()).withInitialDelaySeconds(5).withPeriodSeconds(10).build()).build();
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniInitScriptConfigMap method buildSource.
@NotNull
public HasMetadata buildSource(StackGresDistributedLogsContext context) {
final StackGresDistributedLogs cluster = context.getSource();
String data = Unchecked.supplier(() -> Resources.asCharSource(PatroniInitScriptConfigMap.class.getResource("/09-distributed-logs-template.sql"), StandardCharsets.UTF_8).read()).get();
return new ConfigMapBuilder().withNewMetadata().withNamespace(cluster.getMetadata().getNamespace()).withName(name(cluster)).withLabels(labelFactory.patroniClusterLabels(cluster)).endMetadata().withData(ImmutableMap.of("00000-distributed-logs-template.template1.sql", data)).build();
}
Aggregations