use of io.fabric8.kubernetes.client.Good in project java-operator-sdk by java-operator-sdk.
the class WebPageOperator method main.
public static void main(String[] args) throws IOException {
log.info("WebServer Operator starting!");
Config config = new ConfigBuilder().withNamespace(null).build();
KubernetesClient client = new DefaultKubernetesClient(config);
Operator operator = new Operator(client, DefaultConfigurationService.instance());
operator.register(new WebPageReconciler(client));
operator.installShutdownHook();
operator.start();
new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD!")), 8080).start(Exit.NEVER);
}
use of io.fabric8.kubernetes.client.Good in project java-operator-sdk by java-operator-sdk.
the class MySQLSchemaOperator method main.
public static void main(String[] args) throws IOException {
log.info("MySQL Schema Operator starting");
Config config = new ConfigBuilder().withNamespace(null).build();
KubernetesClient client = new DefaultKubernetesClient(config);
Operator operator = new Operator(client, new ConfigurationServiceOverrider(DefaultConfigurationService.instance()).withMetrics(new MicrometerMetrics(new LoggingMeterRegistry())).build());
operator.register(new MySQLSchemaReconciler(client, MySQLDbConfig.loadFromEnvironmentVars()));
operator.installShutdownHook();
operator.start();
new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD!")), 8080).start(Exit.NEVER);
}
use of io.fabric8.kubernetes.client.Good in project stackgres by ongres.
the class ClusterEventResourceTest method ifEventsAreCreated_itShouldReturnThenInAnArray.
@Test
void ifEventsAreCreated_itShouldReturnThenInAnArray() {
try (KubernetesClient client = factory.create()) {
client.v1().events().inNamespace("test-namespace").create(new EventBuilder().withNewMetadata().withNamespace("test-namespace").withName("test.1").endMetadata().withType("Normal").withMessage("Test").withLastTimestamp(DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(1))).withInvolvedObject(new ObjectReferenceBuilder().withKind(StackGresCluster.KIND).withNamespace("test-namespace").withName("test").withUid("1").build()).build());
client.v1().events().inNamespace("test-namespace").create(new EventBuilder().withNewMetadata().withNamespace("test-namespace").withName("test.2").endMetadata().withType("Normal").withMessage("All good!").withLastTimestamp(DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(2))).withInvolvedObject(new ObjectReferenceBuilder().withKind("StatefulSet").withNamespace("test-namespace").withName("test").withUid("1").build()).build());
client.v1().events().inNamespace("test-namespace").create(new EventBuilder().withNewMetadata().withNamespace("test-namespace").withName("test.3").endMetadata().withType("Warning").withMessage("Something wrong :(").withLastTimestamp(DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(3))).withInvolvedObject(new ObjectReferenceBuilder().withKind("Pod").withNamespace("test-namespace").withName("test-0").withUid("1").build()).build());
client.v1().events().inNamespace("test-namespace").create(new EventBuilder().withNewMetadata().withNamespace("test-namespace").withName("test.4").endMetadata().withType("Normal").withMessage("I am here too").withLastTimestamp(DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(0))).withInvolvedObject(new ObjectReferenceBuilder().withKind(StackGresDbOps.KIND).withNamespace("test-namespace").withName("test-operation").withUid("1").build()).build());
}
given().when().header(AUTHENTICATION_HEADER).get("/stackgres/namespaces/test-namespace/sgclusters/test/events").then().statusCode(200).body("", Matchers.hasSize(4)).body("[0].metadata.name", Matchers.equalTo("test.4")).body("[0].type", Matchers.equalTo("Normal")).body("[0].message", Matchers.equalTo("I am here too")).body("[1].metadata.name", Matchers.equalTo("test.1")).body("[1].type", Matchers.equalTo("Normal")).body("[1].message", Matchers.equalTo("Test")).body("[2].metadata.name", Matchers.equalTo("test.2")).body("[2].type", Matchers.equalTo("Normal")).body("[2].message", Matchers.equalTo("All good!")).body("[3].metadata.name", Matchers.equalTo("test.3")).body("[3].type", Matchers.equalTo("Warning")).body("[3].message", Matchers.equalTo("Something wrong :("));
}
use of io.fabric8.kubernetes.client.Good in project docker-maven-plugin by fabric8io.
the class DockerAssemblyManager method verifyGivenDockerfile.
// visible for testing
void verifyGivenDockerfile(File dockerFile, BuildImageConfiguration buildConfig, FixedStringSearchInterpolator interpolator, Logger log) throws IOException {
AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
if (assemblyConfig == null) {
return;
}
String name = assemblyConfig.getName();
for (String keyword : new String[] { "ADD", "COPY" }) {
List<String[]> lines = DockerFileUtil.extractLines(dockerFile, keyword, interpolator);
for (String[] line : lines) {
if (!line[0].startsWith("#")) {
// Skip command flags like --chown
int i;
for (i = 1; i < line.length; i++) {
String component = line[i];
if (!component.startsWith("--")) {
break;
}
}
// contains an ADD/COPY ... targetDir .... All good.
if (i < line.length && line[i].contains(name)) {
return;
}
}
}
}
log.warn("Dockerfile %s does not contain an ADD or COPY directive to include assembly created at %s. Ignoring assembly.", dockerFile.getPath(), name);
}
use of io.fabric8.kubernetes.client.Good in project fabric8 by jboss-fuse.
the class HealthCheck method healthList.
@Override
public List<HealthStatus> healthList() {
List<HealthStatus> answer = new ArrayList<HealthStatus>();
FabricStatus status = fabricService.getFabricStatus();
Collection<ProfileStatus> statuses = status.getProfileStatusMap().values();
for (ProfileStatus profile : statuses) {
String id = profile.getProfile();
int instances = profile.getCount();
Integer minimum = profile.getMinimumInstances();
Integer maximum = profile.getMaximumInstances();
double healthPercent = profile.getHealth(instances);
String level = "INFO";
String message = "Profile " + id + " has health " + percentInstance.format(healthPercent);
if (minimum != null) {
if (instances <= 0) {
level = "ERROR";
message = "Profile " + id + " has no instances running! Should have at least " + minimum;
} else if (instances < minimum) {
level = "WARNING";
message = "Profile " + id + " needs more instances running. Should have at least " + minimum + " but currently has only " + instances;
}
}
if (maximum != null && level.equals("INFO") && instances > maximum) {
level = "WARNING";
message = "Profile " + id + " has too many instances running. Should have at most " + maximum + " but currently has only " + instances;
}
answer.add(new HealthStatus("io.fabric8.profileHealth", id, level, message, instances, minimum, maximum, healthPercent));
}
String worries = "";
for (HealthStatus hs : answer) {
if ("WARNING".equals(hs.getLevel()) || "ERROR".equals(hs.getLevel())) {
worries += hs + " , ";
}
}
if ("".equals(worries)) {
this.currentStatus = "Good";
} else {
this.currentStatus = "Getting Worried {" + worries + " }";
}
return answer;
}
Aggregations