More resources used by both runner and manager.
This commit is contained in:
parent
d9c2f6edd3
commit
2b471f3852
12 changed files with 62 additions and 22 deletions
|
|
@ -32,6 +32,9 @@ import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import static org.jdrupes.vmoperator.manager.Constants.APP_NAME;
|
||||||
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_NAME;
|
||||||
|
import org.jdrupes.vmoperator.util.K8s;
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
|
|
@ -98,8 +101,8 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
DynamicKubernetesObject newCm) {
|
DynamicKubernetesObject newCm) {
|
||||||
ListOptions listOpts = new ListOptions();
|
ListOptions listOpts = new ListOptions();
|
||||||
listOpts.setLabelSelector(
|
listOpts.setLabelSelector(
|
||||||
"app.kubernetes.io/managed-by=" + Constants.VM_OP_NAME + ","
|
"app.kubernetes.io/managed-by=" + VM_OP_NAME + ","
|
||||||
+ "app.kubernetes.io/name=" + Constants.APP_NAME);
|
+ "app.kubernetes.io/name=" + APP_NAME);
|
||||||
// Get pod, selected by label
|
// Get pod, selected by label
|
||||||
var podApi = new DynamicKubernetesApi("", "v1", "pods", client);
|
var podApi = new DynamicKubernetesApi("", "v1", "pods", client);
|
||||||
var pods = podApi
|
var pods = podApi
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,6 @@ package org.jdrupes.vmoperator.manager;
|
||||||
*/
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
/** The Constant VM_OP_NAME. */
|
|
||||||
public static final String VM_OP_NAME = "vm-operator";
|
|
||||||
|
|
||||||
/** The Constant VM_OP_GROUP. */
|
|
||||||
public static final String VM_OP_GROUP = "vmoperator.jdrupes.org";
|
|
||||||
|
|
||||||
/** The Constant VM_OP_KIND_VM. */
|
|
||||||
public static final String VM_OP_KIND_VM = "VirtualMachine";
|
|
||||||
|
|
||||||
/** The Constant APP_NAME. */
|
/** The Constant APP_NAME. */
|
||||||
public static final String APP_NAME = "vm-runner";
|
public static final String APP_NAME = "vm-runner";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||||
|
import org.jdrupes.vmoperator.util.K8s;
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.apache.commons.cli.CommandLineParser;
|
||||||
import org.apache.commons.cli.DefaultParser;
|
import org.apache.commons.cli.DefaultParser;
|
||||||
import org.apache.commons.cli.Option;
|
import org.apache.commons.cli.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_NAME;
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_NAME;
|
||||||
import org.jdrupes.vmoperator.util.FsdUtils;
|
import org.jdrupes.vmoperator.util.FsdUtils;
|
||||||
import org.jgrapes.core.Component;
|
import org.jgrapes.core.Component;
|
||||||
import org.jgrapes.core.Components;
|
import org.jgrapes.core.Components;
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,12 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_GROUP;
|
|
||||||
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
||||||
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_GROUP;
|
||||||
import org.jdrupes.vmoperator.util.Convertions;
|
import org.jdrupes.vmoperator.util.Convertions;
|
||||||
import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
||||||
|
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||||
|
import org.jdrupes.vmoperator.util.K8s;
|
||||||
import org.jgrapes.core.Channel;
|
import org.jgrapes.core.Channel;
|
||||||
import org.jgrapes.core.Component;
|
import org.jgrapes.core.Component;
|
||||||
import org.jgrapes.core.annotation.Handler;
|
import org.jgrapes.core.annotation.Handler;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||||
|
import org.jdrupes.vmoperator.util.K8s;
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
import org.yaml.snakeyaml.LoaderOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,11 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_GROUP;
|
import static org.jdrupes.vmoperator.manager.Constants.APP_NAME;
|
||||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_KIND_VM;
|
|
||||||
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
||||||
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_GROUP;
|
||||||
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_KIND_VM;
|
||||||
|
import static org.jdrupes.vmoperator.util.Constants.VM_OP_NAME;
|
||||||
import org.jgrapes.core.Channel;
|
import org.jgrapes.core.Channel;
|
||||||
import org.jgrapes.core.Component;
|
import org.jgrapes.core.Component;
|
||||||
import org.jgrapes.core.Components;
|
import org.jgrapes.core.Components;
|
||||||
|
|
@ -132,7 +134,7 @@ public class VmWatcher extends Component {
|
||||||
for (var version : vmOpApiVersions) {
|
for (var version : vmOpApiVersions) {
|
||||||
coa.getAPIResources(VM_OP_GROUP, version)
|
coa.getAPIResources(VM_OP_GROUP, version)
|
||||||
.getResources().stream()
|
.getResources().stream()
|
||||||
.filter(r -> Constants.VM_OP_KIND_VM.equals(r.getKind()))
|
.filter(r -> VM_OP_KIND_VM.equals(r.getKind()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(crd -> watchVmDefs(crd, version));
|
.ifPresent(crd -> watchVmDefs(crd, version));
|
||||||
}
|
}
|
||||||
|
|
@ -148,15 +150,15 @@ public class VmWatcher extends Component {
|
||||||
// Get all known CR instances.
|
// Get all known CR instances.
|
||||||
coa.getAPIResources(VM_OP_GROUP, version)
|
coa.getAPIResources(VM_OP_GROUP, version)
|
||||||
.getResources().stream()
|
.getResources().stream()
|
||||||
.filter(r -> Constants.VM_OP_KIND_VM.equals(r.getKind()))
|
.filter(r -> VM_OP_KIND_VM.equals(r.getKind()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(crd -> known.addAll(getKnown(client, crd, version)));
|
.ifPresent(crd -> known.addAll(getKnown(client, crd, version)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ListOptions opts = new ListOptions();
|
ListOptions opts = new ListOptions();
|
||||||
opts.setLabelSelector(
|
opts.setLabelSelector(
|
||||||
"app.kubernetes.io/managed-by=" + Constants.VM_OP_NAME + ","
|
"app.kubernetes.io/managed-by=" + VM_OP_NAME + ","
|
||||||
+ "app.kubernetes.io/name=" + Constants.APP_NAME);
|
+ "app.kubernetes.io/name=" + APP_NAME);
|
||||||
for (String resource : List.of("apps/v1/statefulsets",
|
for (String resource : List.of("apps/v1/statefulsets",
|
||||||
"v1/configmaps", "v1/secrets")) {
|
"v1/configmaps", "v1/secrets")) {
|
||||||
var resParts = new LinkedList<>(List.of(resource.split("/")));
|
var resParts = new LinkedList<>(List.of(resource.split("/")));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
#Fri Sep 01 16:56:14 CEST 2023
|
#Thu Sep 14 09:53:57 CEST 2023
|
||||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,5 @@ plugins {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.freemarker:freemarker:[2.3.32,2.4)'
|
implementation 'org.freemarker:freemarker:[2.3.32,2.4)'
|
||||||
|
implementation 'io.kubernetes:client-java:[18.0.0,19)'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* VM-Operator
|
||||||
|
* Copyright (C) 2023 Michael N. Lipp
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jdrupes.vmoperator.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some constants.
|
||||||
|
*/
|
||||||
|
public class Constants {
|
||||||
|
|
||||||
|
/** The Constant VM_OP_NAME. */
|
||||||
|
public static final String VM_OP_NAME = "vm-operator";
|
||||||
|
|
||||||
|
/** The Constant VM_OP_GROUP. */
|
||||||
|
public static final String VM_OP_GROUP = "vmoperator.jdrupes.org";
|
||||||
|
|
||||||
|
/** The Constant VM_OP_CRD_NAME. */
|
||||||
|
public static final String VM_OP_CRD_NAME = "vms." + VM_OP_GROUP;
|
||||||
|
|
||||||
|
/** The Constant VM_OP_KIND_VM. */
|
||||||
|
public static final String VM_OP_KIND_VM = "VirtualMachine";
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jdrupes.vmoperator.manager;
|
package org.jdrupes.vmoperator.util;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jdrupes.vmoperator.manager;
|
package org.jdrupes.vmoperator.util;
|
||||||
|
|
||||||
import io.kubernetes.client.common.KubernetesListObject;
|
import io.kubernetes.client.common.KubernetesListObject;
|
||||||
import io.kubernetes.client.common.KubernetesObject;
|
import io.kubernetes.client.common.KubernetesObject;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue