paul-rogers commented on code in PR #13156:
URL: https://github.com/apache/druid/pull/13156#discussion_r984986352


##########
docs/development/extensions-contrib/k8s-jobs.md:
##########
@@ -0,0 +1,96 @@
+---
+id: k8s-jobs
+title: "MM-less Druid in K8s"
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+Consider this an [EXPERIMENTAL](../experimental.md) feature mostly because it 
has not been tested yet on a wide variety of long-running Druid clusters.
+
+Apache Druid Extension to enable using Kubernetes for launching and managing 
tasks instead of the Middle Managers.  This extension allows you to launch 
tasks as K8s jobs removing the need for your middle manager.  
+
+## How it works
+
+It takes the podSpec of your `Overlord`pod and creates a kubernetes job from 
this podSpec.  Thus if you have sidecars such as splunk, hubble, istio it can 
optionally launch a task as a k8s job.  All jobs are natively restorable, they 
are decopled from the druid deployment, thus restarting pods or doing upgrades 
has no affect on tasks in flight.  They will continue to run and when the 
overlord comes back up it will start tracking them again.  

Review Comment:
   Nit: space between `Overlord` and "pod".



##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/JobResponse.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.k8s.overlord.common;
+
+import com.google.common.base.Optional;
+import io.fabric8.kubernetes.api.model.batch.v1.Job;
+import org.apache.druid.indexer.TaskLocation;
+import org.apache.druid.java.util.common.DateTimes;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.joda.time.Period;
+import org.joda.time.PeriodType;
+
+
+public class JobResponse
+{
+
+  private static final EmittingLogger LOGGER = new 
EmittingLogger(JobResponse.class);
+
+  private final Job job;
+  private final PeonPhase phase;
+  private TaskLocation location;
+
+  public JobResponse(Job job, PeonPhase phase)
+  {
+    this.job = job;
+    this.phase = phase;
+  }
+
+  public Job getJob()
+  {
+    return job;
+  }
+
+  public PeonPhase getPhase()
+  {
+    return phase;
+  }
+
+  public TaskLocation getLocation()
+  {
+    return location;
+  }
+
+  public void setLocation(TaskLocation location)
+  {
+    this.location = location;
+  }
+
+  public Optional<Long> getJobDuration()
+  {
+    Optional<Long> duration = Optional.absent();
+    try {
+      if (job.getStatus() != null) {
+        if (job.getStatus().getStartTime() != null) {
+          if (job.getStatus().getCompletionTime() != null) {

Review Comment:
   Nit: and together the conditions, since the only logic appears where all 
thee conditions are true.



##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/common/K8sTaskAdapter.java:
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.k8s.overlord.common;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import io.fabric8.kubernetes.api.model.Container;
+import io.fabric8.kubernetes.api.model.ContainerPort;
+import io.fabric8.kubernetes.api.model.EnvVar;
+import io.fabric8.kubernetes.api.model.EnvVarBuilder;
+import io.fabric8.kubernetes.api.model.EnvVarSourceBuilder;
+import io.fabric8.kubernetes.api.model.ObjectFieldSelector;
+import io.fabric8.kubernetes.api.model.ObjectMeta;
+import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.api.model.PodSpec;
+import io.fabric8.kubernetes.api.model.PodTemplateSpec;
+import io.fabric8.kubernetes.api.model.Quantity;
+import io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder;
+import io.fabric8.kubernetes.api.model.batch.v1.Job;
+import io.fabric8.kubernetes.api.model.batch.v1.JobBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.druid.indexing.common.task.Task;
+import org.apache.druid.java.util.common.HumanReadableBytes;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.k8s.overlord.KubernetesTaskRunnerConfig;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * This class transforms tasks to pods, and pods to tasks to assist with 
creating the job spec for a
+ * peon task.
+ * The two subclasses of this class are the SingleContainerTaskAdapter and the 
MultiContainerTaskAdapter
+ * This class runs on the overlord, to convert a task into a job, it will take 
its own podSpec (the current running overlord)
+ * keep volumees, secrets, env variables, config maps, etc..and add some 
additional information as well as provide a new

Review Comment:
   Nit: misspelling of "volumees"
   
   Nit: "maps, etc..and" --> "maps, etc. and"



##########
services/src/test/java/org/apache/druid/cli/CliPeonTest.java:
##########
@@ -0,0 +1,73 @@
+package org.apache.druid.cli;

Review Comment:
   Checkstyle will complain due to lack of license header. Suggestion: run 
checkstyle before each commit, it is fast:
   
   ```bash
   mvn checkstyle:checkstyle -nsu
   ```



##########
extensions-contrib/kubernetes-overlord-extensions/src/test/resources/expectedMultiContainerOutput.yaml:
##########
@@ -0,0 +1,108 @@
+apiVersion: "batch/v1"
+kind: "Job"
+metadata:
+  annotations:
+    task.id: "id"
+    tls.enabled: "false"
+  labels:
+    druid.k8s.peons: "true"
+  name: "id"
+spec:
+  activeDeadlineSeconds: 14400
+  backoffLimit: 0
+  template:
+    metadata:
+      annotations:
+        task.id: "id"
+        tls.enabled: "false"
+      labels:
+        druid.k8s.peons: "true"
+    spec:
+      hostname: "id"
+      containers:
+        - args:
+            - "/kubexit/kubexit /bin/sh -c \"/peon.sh 
/druid/data/baseTaskDir/noop_2022-09-26T22:08:00.582Z_352988d2-5ff7-4b70-977c-3de96f9bfca6
 1\""
+          command:
+            - "/bin/sh"
+            - "-c"
+          env:
+            - name: "TASK_DIR"
+              value: "/tmp"
+            - name: "TASK_JSON"
+              value: 
"H4sIAAAAAAAAAEVOOw7CMAy9i+cOBYmlK0KItWVhNI0BSyEOToKoqt4doxZYLPv9/EbIQyRoIIhEqICd7TYquKqUePidDjN2UrSfxYEM0xKOfDdgvalr86aW0A0z9L9bSsVnc512nZkurHSTZJJQvK+gl5DpZfwIUVmU8wDNarJ0Ssu/EfCJ7PHM3tj9p9i3ltKjWKDbYsR+sU5vP86oMNUAAAA="
+            - name: "JAVA_OPTS"
+              value: ""
+            - name: "druid_host"
+              valueFrom:
+                fieldRef:
+                  fieldPath: "status.podIP"
+            - name: "HOSTNAME"
+              valueFrom:
+                fieldRef:
+                  fieldPath: "metadata.name"
+            - name: "KUBEXIT_NAME"
+              value: "main"
+            - name: "KUBEXIT_GRAVEYARD"
+              value: "/graveyard"
+
+          image: "one"
+          name: "main"
+          ports:
+            - containerPort: 8091
+              name: "druid-tls-port"
+              protocol: "TCP"
+            - containerPort: 8100
+              name: "druid-port"
+              protocol: "TCP"
+          resources:
+            limits:
+              cpu: "1000m"
+              memory: "2400000000"
+            requests:
+              cpu: "1000m"
+              memory: "2400000000"
+          volumeMounts:
+            - mountPath: "/graveyard"
+              name: "graveyard"
+            - mountPath: "/kubexit"
+              name: "kubexit"
+        - args:
+            - "/kubexit/kubexit /bin/sh -c \"/bin/sidekick 
-loggingEnabled=true -platform=platform\
+          \ -splunkCluster=cluster -splunkIndexName=druid 
-splunkSourceType=json -splunkWorkingDir=/opt/splunkforwarder\
+          \ -dataCenter=dc -environment=env -application=druid 
-instance=instance\
+          \ -logFiles=/logs/druid/*.log\" || true"
+          command:
+            - "/bin/sh"
+            - "-c"
+          env:
+            - name: "KUBEXIT_NAME"
+              value: "sidecar"
+            - name: "KUBEXIT_GRAVEYARD"
+              value: "/graveyard"
+            - name: "KUBEXIT_DEATH_DEPS"
+              value: "main"
+          image: "two"
+          name: "sidecar"
+          volumeMounts:
+            - mountPath: "/graveyard"
+              name: "graveyard"
+            - mountPath: "/kubexit"
+              name: "kubexit"
+      initContainers:
+        - command:
+            - "cp"
+            - "/bin/kubexit"
+            - "/kubexit/kubexit"
+          image: "karlkfi/kubexit:v0.3.2"
+          name: "kubexit"
+          volumeMounts:
+            - mountPath: "/kubexit"
+              name: "kubexit"
+      restartPolicy: "Never"
+      volumes:
+        - emptyDir:
+            medium: "Memory"
+          name: "graveyard"
+        - emptyDir: {}
+          name: "kubexit"
+  ttlSecondsAfterFinished: 172800

Review Comment:
   Nit: missing newline, here and below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to