diff --git a/.idea/modules.xml b/.idea/modules.xml index 79441dae..f8a48ba8 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -7,6 +7,9 @@ + + + diff --git a/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.iml b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.iml new file mode 100644 index 00000000..2ea504fd --- /dev/null +++ b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.main.iml b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.main.iml new file mode 100644 index 00000000..bacd7ca1 --- /dev/null +++ b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.main.iml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/4.11.0/436932d695b2c43f2c86b8111c596179cd133d56/okhttp-4.11.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio-jvm/3.2.0/332d1c5dc82b0241cb1d35bb0901d28470cc89ca/okio-jvm-3.2.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.8.0/ed04f49e186a116753ad70d34f0ac2925d1d8020/kotlin-stdlib-jdk8-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.10.1/b3add478d4382b78ea20b1671390a858002feb6c/gson-2.10.1.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.8.0/3c91271347f678c239607abb676d4032a7898427/kotlin-stdlib-jdk7-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.0/1796921c7a3e2e2665a83e6c8d33399336cd39bc/kotlin-stdlib-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.0/f7197e7cc76453ac59f8b0f8d5137cc600becd36/kotlin-stdlib-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar + + + + + + + + + + + + + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.8.0/1f7345b3fc46786c1f36a4ba0728a95990d05929/kotlin-scripting-jvm-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.8.0/ffeb4c0c2b3978876b993d6b55646e6b567077a8/kotlin-scripting-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.0/1796921c7a3e2e2665a83e6c8d33399336cd39bc/kotlin-stdlib-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.0/f7197e7cc76453ac59f8b0f8d5137cc600becd36/kotlin-stdlib-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.8.0/b2f7e760d283cb339974851c222a4c1d48f2d3d/kotlin-script-runtime-1.8.0.jar + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.test.iml b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.test.iml new file mode 100644 index 00000000..e4cfee18 --- /dev/null +++ b/.idea/modules/packages/shulker-java-sdk/shulker.packages.shulker-java-sdk.test.iml @@ -0,0 +1,84 @@ + + + + + + :packages:shulker-java-sdk:main + + + + + + + + + + + $MODULE_DIR$/../../../../dist/packages/shulker-java-sdk/classes/kotlin/main + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/4.11.0/436932d695b2c43f2c86b8111c596179cd133d56/okhttp-4.11.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio-jvm/3.2.0/332d1c5dc82b0241cb1d35bb0901d28470cc89ca/okio-jvm-3.2.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.8.0/ed04f49e186a116753ad70d34f0ac2925d1d8020/kotlin-stdlib-jdk8-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.10.1/b3add478d4382b78ea20b1671390a858002feb6c/gson-2.10.1.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-junit/1.8.0/d2f0489c492f06152eac8a7c4029e92e05205153/kotlin-test-junit-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test/1.8.0/cbc4be6bae290df37622e1b3221281d14ba24aa/kotlin-test-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.8.0/3c91271347f678c239607abb676d4032a7898427/kotlin-stdlib-jdk7-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.0/1796921c7a3e2e2665a83e6c8d33399336cd39bc/kotlin-stdlib-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.0/f7197e7cc76453ac59f8b0f8d5137cc600becd36/kotlin-stdlib-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.13.2/8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12/junit-4.13.2.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar + + + + + + + + + + + + $MODULE_DIR$/../../../../dist/packages/shulker-java-sdk/classes/java/main + $MODULE_DIR$/../../../../dist/packages/shulker-java-sdk/classes/kotlin/main + $MODULE_DIR$/../../../../dist/packages/shulker-java-sdk/libs/shulker-java-sdk-0.1.0.jar + + + + + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.8.0/1f7345b3fc46786c1f36a4ba0728a95990d05929/kotlin-scripting-jvm-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.8.0/ffeb4c0c2b3978876b993d6b55646e6b567077a8/kotlin-scripting-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.0/1796921c7a3e2e2665a83e6c8d33399336cd39bc/kotlin-stdlib-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.0/f7197e7cc76453ac59f8b0f8d5137cc600becd36/kotlin-stdlib-common-1.8.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar + $USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.8.0/b2f7e760d283cb339974851c222a4c1d48f2d3d/kotlin-script-runtime-1.8.0.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml index fb632afc..c93e0ce3 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml @@ -4,6 +4,7 @@ + BUNGEECORD ADVENTURE diff --git a/kube/resources/components/shulker-operator/operator.yaml b/kube/resources/components/shulker-operator/operator.yaml index 3a30eedc..ad592a68 100644 --- a/kube/resources/components/shulker-operator/operator.yaml +++ b/kube/resources/components/shulker-operator/operator.yaml @@ -118,14 +118,6 @@ spec: operator: In values: - linux - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - preference: - matchExpressions: - - key: node-role.shulkermc.io/control-plane - operator: In - values: - - "true" securityContext: runAsNonRoot: true seccompProfile: diff --git a/kube/resources/crd/bases/shulkermc.io_minecraftserverfleets.yaml b/kube/resources/crd/bases/shulkermc.io_minecraftserverfleets.yaml index 085250fc..a510a22d 100644 --- a/kube/resources/crd/bases/shulkermc.io_minecraftserverfleets.yaml +++ b/kube/resources/crd/bases/shulkermc.io_minecraftserverfleets.yaml @@ -165,17 +165,6 @@ spec: required: - type type: object - shulkerPolicy: - description: Custom policy implemented by Shulker to apply to - the autoscaling target. Mutually exclusive with AgonesPolicy. - properties: - type: - description: Name of the policy to apply. Some policies may - not be implemented depending on the target resource. - enum: - - ManualSummon - type: string - type: object type: object clusterRef: description: Reference to a MinecraftCluster. Adding this will enroll diff --git a/kube/resources/crd/bases/shulkermc.io_proxyfleets.yaml b/kube/resources/crd/bases/shulkermc.io_proxyfleets.yaml index 1de8a1b3..db3cad32 100644 --- a/kube/resources/crd/bases/shulkermc.io_proxyfleets.yaml +++ b/kube/resources/crd/bases/shulkermc.io_proxyfleets.yaml @@ -164,17 +164,6 @@ spec: required: - type type: object - shulkerPolicy: - description: Custom policy implemented by Shulker to apply to - the autoscaling target. Mutually exclusive with AgonesPolicy. - properties: - type: - description: Name of the policy to apply. Some policies may - not be implemented depending on the target resource. - enum: - - ManualSummon - type: string - type: object type: object clusterRef: description: Reference to a MinecraftCluster. Adding this will enroll @@ -1589,8 +1578,6 @@ spec: required: - version type: object - required: - - spec type: object required: - replicas diff --git a/packages/shulker-crds/v1alpha1/autoscaling_types.go b/packages/shulker-crds/v1alpha1/autoscaling_types.go index ee5e626c..45f94cb9 100644 --- a/packages/shulker-crds/v1alpha1/autoscaling_types.go +++ b/packages/shulker-crds/v1alpha1/autoscaling_types.go @@ -9,22 +9,17 @@ type FleetAutoscalingSpec struct { // target. Mutually exclusive with ShulkerPolicy. // +optional AgonesPolicy *agonesautoscalingv1.FleetAutoscalerPolicy `json:"agonesPolicy,omitempty"` - - // Custom policy implemented by Shulker to apply to the - // autoscaling target. Mutually exclusive with AgonesPolicy. - // +optional - ShulkerPolicy *FleetAutoscalingShulkerPolicySpec `json:"shulkerPolicy,omitempty"` } -// +kubebuilder:validation:Enum=ManualSummon -type FleetAutoscalingShulkerPolicyType string +// // +kubebuilder:validation:Enum=ManualSummon +// type FleetAutoscalingShulkerPolicyType string -const ( - FleetAutoscalingShulkerPolicyManualSummon FleetAutoscalingShulkerPolicyType = "ManualSummon" -) +// const ( +// FleetAutoscalingShulkerPolicyManualSummon FleetAutoscalingShulkerPolicyType = "ManualSummon" +// ) -type FleetAutoscalingShulkerPolicySpec struct { - // Name of the policy to apply. Some policies may not be - // implemented depending on the target resource. - Type FleetAutoscalingShulkerPolicyType `json:"type,omitempty"` -} +// type FleetAutoscalingShulkerPolicySpec struct { +// // Name of the policy to apply. Some policies may not be +// // implemented depending on the target resource. +// Type FleetAutoscalingShulkerPolicyType `json:"type,omitempty"` +// } diff --git a/packages/shulker-crds/v1alpha1/zz_generated.deepcopy.go b/packages/shulker-crds/v1alpha1/zz_generated.deepcopy.go index 1a40aa3f..9a24a22c 100644 --- a/packages/shulker-crds/v1alpha1/zz_generated.deepcopy.go +++ b/packages/shulker-crds/v1alpha1/zz_generated.deepcopy.go @@ -17,21 +17,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscalingShulkerPolicySpec) DeepCopyInto(out *FleetAutoscalingShulkerPolicySpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalingShulkerPolicySpec. -func (in *FleetAutoscalingShulkerPolicySpec) DeepCopy() *FleetAutoscalingShulkerPolicySpec { - if in == nil { - return nil - } - out := new(FleetAutoscalingShulkerPolicySpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FleetAutoscalingSpec) DeepCopyInto(out *FleetAutoscalingSpec) { *out = *in @@ -40,11 +25,6 @@ func (in *FleetAutoscalingSpec) DeepCopyInto(out *FleetAutoscalingSpec) { *out = new(v1.FleetAutoscalerPolicy) (*in).DeepCopyInto(*out) } - if in.ShulkerPolicy != nil { - in, out := &in.ShulkerPolicy, &out.ShulkerPolicy - *out = new(FleetAutoscalingShulkerPolicySpec) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalingSpec. diff --git a/packages/shulker-java-sdk/build.gradle.kts b/packages/shulker-java-sdk/build.gradle.kts new file mode 100644 index 00000000..c7311bce --- /dev/null +++ b/packages/shulker-java-sdk/build.gradle.kts @@ -0,0 +1,10 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +dependencies { + implementation("com.squareup.okhttp3:okhttp:4.11.0") + implementation("com.google.code.gson:gson:2.10.1") +} + +tasks.withType { + mergeServiceFiles() +} diff --git a/packages/shulker-java-sdk/project.json b/packages/shulker-java-sdk/project.json new file mode 100644 index 00000000..35182baa --- /dev/null +++ b/packages/shulker-java-sdk/project.json @@ -0,0 +1,32 @@ +{ + "name": "shulker-java-sdk", + "root": "packages/shulker-java-sdk", + "sourceRoot": "packages/shulker-java-sdk/src", + "projectType": "application", + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": ["dist/packages/shulker-java-sdk"], + "options": { + "command": "gradle :packages:shulker-java-sdk:build -x check" + }, + "inputs": ["default", "java:dependencies"] + }, + "test": { + "executor": "nx:run-commands", + "options": { + "command": "gradle :packages:shulker-java-sdk:test" + }, + "inputs": ["default", "java:dependencies"] + }, + "lint": { + "executor": "nx:run-commands", + "options": { + "command": "gradle :packages:shulker-java-sdk:ktlintCheck" + }, + "inputs": ["default", "java:dependencies"] + } + }, + "tags": ["lang:java"], + "implicitDependencies": ["shulker-proxy-api"] +} diff --git a/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPI.kt b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPI.kt new file mode 100644 index 00000000..7a57eaf4 --- /dev/null +++ b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPI.kt @@ -0,0 +1,9 @@ +package io.shulkermc.api + +import io.shulkermc.api.domain.GameServer +import io.shulkermc.api.domain.NamespaceKey +import java.util.concurrent.CompletableFuture + +interface ShulkerAPI { + fun summonGameServer(fleetNamespaceKey: NamespaceKey): CompletableFuture +} diff --git a/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPIHttp.kt b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPIHttp.kt new file mode 100644 index 00000000..7e43898d --- /dev/null +++ b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/ShulkerAPIHttp.kt @@ -0,0 +1,69 @@ +package io.shulkermc.api + +import com.google.gson.Gson +import io.shulkermc.api.domain.GameServer +import io.shulkermc.api.domain.NamespaceKey +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.RequestBody.Companion.toRequestBody +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executors + +class ShulkerAPIHttp(private val host: String, private val port: Int) : ShulkerAPI { + companion object { + fun createFromEnvironment(): ShulkerAPI { + return Builder() + .withHost(checkNotNull(System.getenv("SHULKER_API_HOST")) { "Missing SHULKER_API_HOST environment variable" }) + .withPort(checkNotNull(System.getenv("SHULKER_API_PORT")) { "Missing SHULKER_API_PORT environment variable" }.toInt()) + .build() + } + } + + @Suppress("HttpUrlsUsage") + private val baseUrl = "http://${this.host}:${this.port}" + private val client = OkHttpClient() + + private val executor = Executors.newCachedThreadPool() + + override fun summonGameServer(fleetNamespaceKey: NamespaceKey): CompletableFuture { + val request = Request.Builder() + .url("${this.baseUrl}/minecraftserverfleets/${fleetNamespaceKey.namespace}/${fleetNamespaceKey.name}/summon") + .post("text/plain".toRequestBody()) + .build() + + val future = CompletableFuture() + + this.executor.submit { + this.client.newCall(request).execute().use { response -> + if (!response.isSuccessful) { + future.completeExceptionally(RuntimeException("Unexpected HTTP status ${response.code}")) + } else { + val gameServer = Gson().fromJson(response.body!!.charStream(), GameServer::class.java) + future.complete(gameServer) + } + } + } + + return future + } + + class Builder { + private var host: String? = null + private var port: Int = 80 + + fun build(): ShulkerAPI = ShulkerAPIHttp( + checkNotNull(this.host), + this.port + ) + + fun withHost(host: String): Builder { + this.host = host + return this + } + + fun withPort(port: Int): Builder { + this.port = port + return this + } + } +} diff --git a/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/GameServer.kt b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/GameServer.kt new file mode 100644 index 00000000..c6b7ec0a --- /dev/null +++ b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/GameServer.kt @@ -0,0 +1,3 @@ +package io.shulkermc.api.domain + +data class GameServer(val namespace: String, val name: String) diff --git a/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/NamespaceKey.kt b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/NamespaceKey.kt new file mode 100644 index 00000000..f99e484d --- /dev/null +++ b/packages/shulker-java-sdk/src/main/kotlin/io/shulkermc/api/domain/NamespaceKey.kt @@ -0,0 +1,3 @@ +package io.shulkermc.api.domain + +data class NamespaceKey(val namespace: String, val name: String) diff --git a/packages/shulker-operator/src/resources/minecraftserver/gameserver.go b/packages/shulker-operator/src/resources/minecraftserver/gameserver.go index a56f2800..80d557d3 100644 --- a/packages/shulker-operator/src/resources/minecraftserver/gameserver.go +++ b/packages/shulker-operator/src/resources/minecraftserver/gameserver.go @@ -186,6 +186,9 @@ func (b *MinecraftServerResourceGameServerBuilder) GetGameServerSpec() (*agonesv Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: b.getLabels(), + Annotations: map[string]string{ + "minecraftserver.shulkermc.io/tags": strings.Join(b.Instance.Spec.Tags, ","), + }, }, Spec: podSpec, }, diff --git a/packages/shulker-operator/src/resources/minecraftserverfleet/fleet.go b/packages/shulker-operator/src/resources/minecraftserverfleet/fleet.go index a154fc92..a646d327 100644 --- a/packages/shulker-operator/src/resources/minecraftserverfleet/fleet.go +++ b/packages/shulker-operator/src/resources/minecraftserverfleet/fleet.go @@ -7,7 +7,6 @@ package resources import ( "fmt" - "strings" agonesapis "agones.dev/agones/pkg/apis" agonesv1 "agones.dev/agones/pkg/apis/agones/v1" @@ -70,6 +69,18 @@ func (b *MinecraftServerFleetResourceFleetBuilder) Update(object client.Object) replicas = int32(b.Instance.Spec.Replicas) } + if b.Instance.Spec.Template.ObjectMeta.Labels != nil { + for k, v := range b.Instance.Spec.Template.ObjectMeta.Labels { + gameServerSpec.Template.Labels[k] = v + } + } + + if b.Instance.Spec.Template.ObjectMeta.Annotations != nil { + for k, v := range b.Instance.Spec.Template.ObjectMeta.Annotations { + gameServerSpec.Template.Annotations[k] = v + } + } + fleet.Spec = agonesv1.FleetSpec{ Replicas: replicas, Strategy: appsv1.DeploymentStrategy{ @@ -88,10 +99,8 @@ func (b *MinecraftServerFleetResourceFleetBuilder) Update(object client.Object) Scheduling: agonesapis.Packed, Template: agonesv1.GameServerTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: b.getLabels(), - Annotations: map[string]string{ - "minecraftserver.shulkermc.io/tags": strings.Join(b.Instance.Spec.Template.Spec.Tags, ","), - }, + Labels: gameServerSpec.Template.Labels, + Annotations: gameServerSpec.Template.Annotations, }, Spec: *gameServerSpec, }, diff --git a/packages/shulker-operator/src/resources/proxyfleet/builder.go b/packages/shulker-operator/src/resources/proxyfleet/builder.go index 92ed9a0a..141120ac 100644 --- a/packages/shulker-operator/src/resources/proxyfleet/builder.go +++ b/packages/shulker-operator/src/resources/proxyfleet/builder.go @@ -75,15 +75,7 @@ func (b *ProxyFleetResourceBuilder) getLabels() map[string]string { "app.kubernetes.io/name": b.Instance.Name, "app.kubernetes.io/component": "proxy", "minecraftcluster.shulkermc.io/name": b.Instance.Spec.ClusterRef.Name, - } - - for _, ownerReference := range b.Instance.OwnerReferences { - if *ownerReference.Controller { - labels["app.kubernetes.io/name"] = ownerReference.Name - labels["app.kubernetes.io/instance"] = b.Instance.Name - labels["proxyfleet.shulkermc.io/name"] = ownerReference.Name - break - } + "proxyfleet.shulkermc.io/name": b.Instance.Name, } return labels diff --git a/packages/shulker-operator/src/resources/proxyfleet/fleet.go b/packages/shulker-operator/src/resources/proxyfleet/fleet.go index 3f034105..25bf185a 100644 --- a/packages/shulker-operator/src/resources/proxyfleet/fleet.go +++ b/packages/shulker-operator/src/resources/proxyfleet/fleet.go @@ -79,7 +79,8 @@ func (b *ProxyFleetResourceFleetBuilder) Update(object client.Object) error { Scheduling: agonesapis.Packed, Template: agonesv1.GameServerTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: b.getLabels(), + Labels: gameServerSpec.Template.Labels, + Annotations: gameServerSpec.Template.Annotations, }, Spec: *gameServerSpec, }, @@ -226,6 +227,20 @@ func (b *ProxyFleetResourceFleetBuilder) getGameServerSpec() (*agonesv1.GameServ podSpec.Tolerations = b.Instance.Spec.Template.Spec.PodOverrides.Tolarations } + labels := b.getLabels() + if b.Instance.Spec.Template.ObjectMeta.Labels != nil { + for k, v := range b.Instance.Spec.Template.ObjectMeta.Labels { + labels[k] = v + } + } + + annotations := make(map[string]string) + if b.Instance.Spec.Template.ObjectMeta.Annotations != nil { + for k, v := range b.Instance.Spec.Template.ObjectMeta.Annotations { + annotations[k] = v + } + } + gameServerSpec := agonesv1.GameServerSpec{ // Ports: []agonesv1.GameServerPort{{ // Name: "minecraft", @@ -244,7 +259,8 @@ func (b *ProxyFleetResourceFleetBuilder) getGameServerSpec() (*agonesv1.GameServ }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: b.Instance.Spec.Template.ObjectMeta.Labels, + Labels: labels, + Annotations: annotations, }, Spec: podSpec, }, diff --git a/packages/shulker-proxy-agent/src/common/kotlin/io/shulkermc/proxyagent/features/drain/DrainFeature.kt b/packages/shulker-proxy-agent/src/common/kotlin/io/shulkermc/proxyagent/features/drain/DrainFeature.kt index a3fccf1b..1482b2f8 100644 --- a/packages/shulker-proxy-agent/src/common/kotlin/io/shulkermc/proxyagent/features/drain/DrainFeature.kt +++ b/packages/shulker-proxy-agent/src/common/kotlin/io/shulkermc/proxyagent/features/drain/DrainFeature.kt @@ -26,7 +26,7 @@ class DrainFeature( ) } - private lateinit var ttlTask: ProxyInterface.ScheduledTask + private var ttlTask: ProxyInterface.ScheduledTask private var acceptingPlayers = true private var drained = false diff --git a/settings.gradle b/settings.gradle index 7f32f19c..e5000f0f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,6 @@ rootProject.name = "shulker" +include ':packages:shulker-java-sdk' include ':packages:shulker-agones-java-sdk' include ':packages:shulker-proxy-api' include ':packages:shulker-proxy-agent'