use of org.bf2.operator.resources.v1alpha1.ServiceAccount in project gapic-generator-java by googleapis.
the class SyncGetServiceAccountProjectname method syncGetServiceAccountProjectname.
public static void syncGetServiceAccountProjectname() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
ServiceAccount response = storageClient.getServiceAccount(project);
}
}
use of org.bf2.operator.resources.v1alpha1.ServiceAccount in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaCluster method addQuotaConfig.
private void addQuotaConfig(ManagedKafka managedKafka, Kafka current, Map<String, Object> config) {
config.put("client.quota.callback.class", IO_STRIMZI_KAFKA_QUOTA_STATIC_QUOTA_CALLBACK);
// Throttle at Ingress/Egress MB/sec per broker
config.put(QUOTA_PRODUCE, String.valueOf(getIngressBytes(managedKafka, current)));
config.put(QUOTA_FETCH, String.valueOf(getEgressBytes(managedKafka, current)));
// Start throttling when disk is above requested size. Full stop when only storageMinMargin is free.
Quantity maxDataRetentionSize = getAdjustedMaxDataRetentionSize(managedKafka, current);
long hardStorageLimit = Quantity.getAmountInBytes(maxDataRetentionSize).longValue() - Quantity.getAmountInBytes(storageMinMargin).longValue();
long softStorageLimit = Quantity.getAmountInBytes(maxDataRetentionSize).longValue() - getStoragePadding(managedKafka, current);
config.put("client.quota.callback.static.storage.soft", String.valueOf(softStorageLimit));
config.put("client.quota.callback.static.storage.hard", String.valueOf(hardStorageLimit));
// Check storage every storageCheckInterval seconds
config.put("client.quota.callback.static.storage.check-interval", String.valueOf(storageCheckInterval));
// Configure the quota plugin so that the canary is not subjected to the quota checks.
Optional<ServiceAccount> canaryServiceAccount = managedKafka.getServiceAccount(ServiceAccount.ServiceAccountName.Canary);
canaryServiceAccount.ifPresent(serviceAccount -> config.put("client.quota.callback.static.excluded.principal.name.list", serviceAccount.getPrincipal()));
config.put("quota.window.num", "30");
config.put("quota.window.size.seconds", "2");
}
use of org.bf2.operator.resources.v1alpha1.ServiceAccount in project gapic-generator-java by googleapis.
the class SyncGetServiceAccountString method syncGetServiceAccountString.
public static void syncGetServiceAccountString() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
String project = ProjectName.of("[PROJECT]").toString();
ServiceAccount response = storageClient.getServiceAccount(project);
}
}
use of org.bf2.operator.resources.v1alpha1.ServiceAccount in project yakc by manusa.
the class AuthIT method retrieveSecretForServiceAccount.
private Secret retrieveSecretForServiceAccount() throws IOException {
final ServiceAccount sa = KC.create(CoreV1Api.class).listNamespacedServiceAccount(NAMESPACE).stream().findFirst().orElseThrow(() -> new AssertionError("No Service Account found"));
final String secretName = sa.getSecrets() == null ? null : sa.getSecrets().stream().findFirst().map(ObjectReference::getName).orElse(null);
if (secretName != null) {
return KC.create(CoreV1Api.class).listNamespacedSecret(NAMESPACE).stream().filter(s -> s.getType().equals("kubernetes.io/service-account-token")).filter(s -> s.getMetadata().getName().equals(secretName)).findAny().orElseThrow(() -> new AssertionError(String.format("Secret %s doesn't exist", secretName)));
} else {
// https://kubernetes.io/docs/concepts/configuration/secret/#service-account-token-secrets
final Secret serviceAccountTokenSecret = Secret.builder().metadata(ObjectMeta.builder().name(sa.getMetadata().getName() + "-token").putInAnnotations("kubernetes.io/service-account.name", sa.getMetadata().getName()).build()).type("kubernetes.io/service-account-token").putInStringData("token", "my-secret-token").build();
return KC.create(CoreV1Api.class).createNamespacedSecret(NAMESPACE, serviceAccountTokenSecret).get();
}
}
use of org.bf2.operator.resources.v1alpha1.ServiceAccount in project yakc by manusa.
the class ServiceAccountIT method deleteNamespacedServiceAccount.
@Test
@DisplayName("deleteNamespacedServiceAccount, should delete existing ServiceAccount")
void deleteNamespacedServiceAccount() throws IOException {
// When
final ServiceAccount result = KC.create(CoreV1Api.class).deleteNamespacedServiceAccount(serviceAccountName, NAMESPACE, DeleteOptions.builder().propagationPolicy("Background").build()).get();
// Then
assertThat(result).isNotNull().extracting(ServiceAccount::getMetadata).hasFieldOrPropertyWithValue("name", serviceAccountName);
}
Aggregations