diff --git a/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplication.java b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplication.java new file mode 100644 index 00000000..94a9ea3c --- /dev/null +++ b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplication.java @@ -0,0 +1,68 @@ +/* + * 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.spark.k8s.operator.v1alpha1; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.ShortNames; +import io.fabric8.kubernetes.model.annotation.Version; + +import org.apache.spark.k8s.operator.BaseResource; +import org.apache.spark.k8s.operator.Constants; +import org.apache.spark.k8s.operator.spec.ApplicationSpec; +import org.apache.spark.k8s.operator.status.ApplicationAttemptSummary; +import org.apache.spark.k8s.operator.status.ApplicationState; +import org.apache.spark.k8s.operator.status.ApplicationStateSummary; +import org.apache.spark.k8s.operator.status.ApplicationStatus; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonDeserialize() +@Group(Constants.API_GROUP) +@Version(value = "v1alpha1", storage = false) +@ShortNames({"sparkapp"}) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SparkApplication + extends BaseResource< + ApplicationStateSummary, + ApplicationAttemptSummary, + ApplicationState, + ApplicationSpec, + ApplicationStatus> { + @Override + public ApplicationStatus initStatus() { + return new ApplicationStatus(); + } + + @Override + public ApplicationSpec initSpec() { + return new ApplicationSpec(); + } + + public org.apache.spark.k8s.operator.SparkApplication asLatestSparkApplication() { + org.apache.spark.k8s.operator.SparkApplication app = + new org.apache.spark.k8s.operator.SparkApplication(); + app.setMetadata(getMetadata()); + app.setSpec(spec); + app.setStatus(status); + return app; + } +} diff --git a/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplicationList.java b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplicationList.java new file mode 100644 index 00000000..d39d63a2 --- /dev/null +++ b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkApplicationList.java @@ -0,0 +1,26 @@ +/* + * 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.spark.k8s.operator.v1alpha1; + +import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class SparkApplicationList extends DefaultKubernetesResourceList {} diff --git a/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkCluster.java b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkCluster.java new file mode 100644 index 00000000..d532d8b7 --- /dev/null +++ b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkCluster.java @@ -0,0 +1,64 @@ +/* + * 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.spark.k8s.operator.v1alpha1; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import io.fabric8.kubernetes.model.annotation.Group; +import io.fabric8.kubernetes.model.annotation.ShortNames; +import io.fabric8.kubernetes.model.annotation.Version; + +import org.apache.spark.k8s.operator.BaseResource; +import org.apache.spark.k8s.operator.Constants; +import org.apache.spark.k8s.operator.spec.ClusterSpec; +import org.apache.spark.k8s.operator.status.ClusterAttemptSummary; +import org.apache.spark.k8s.operator.status.ClusterState; +import org.apache.spark.k8s.operator.status.ClusterStateSummary; +import org.apache.spark.k8s.operator.status.ClusterStatus; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonDeserialize() +@Group(Constants.API_GROUP) +@Version(value = "v1alpha1", storage = false) +@ShortNames({"sparkcluster"}) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SparkCluster + extends BaseResource< + ClusterStateSummary, ClusterAttemptSummary, ClusterState, ClusterSpec, ClusterStatus> { + @Override + public ClusterStatus initStatus() { + return new ClusterStatus(); + } + + @Override + public ClusterSpec initSpec() { + return new ClusterSpec(); + } + + public org.apache.spark.k8s.operator.SparkCluster asLatestSparkCluster() { + org.apache.spark.k8s.operator.SparkCluster cluster = + new org.apache.spark.k8s.operator.SparkCluster(); + cluster.setMetadata(getMetadata()); + cluster.setSpec(spec); + cluster.setStatus(status); + return cluster; + } +} diff --git a/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkClusterList.java b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkClusterList.java new file mode 100644 index 00000000..b8028c34 --- /dev/null +++ b/spark-operator-api/src/main/java/org/apache/spark/k8s/operator/v1alpha1/SparkClusterList.java @@ -0,0 +1,26 @@ +/* + * 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.spark.k8s.operator.v1alpha1; + +import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class SparkClusterList extends DefaultKubernetesResourceList {} diff --git a/spark-operator-api/src/main/resources/printer-columns.sh b/spark-operator-api/src/main/resources/printer-columns.sh index f49d2b26..d6d66843 100755 --- a/spark-operator-api/src/main/resources/printer-columns.sh +++ b/spark-operator-api/src/main/resources/printer-columns.sh @@ -21,7 +21,7 @@ # We do a yq to add printer columns SCRIPT_PATH=$(cd "$(dirname "$0")"; pwd) +printerColumns='"additionalPrinterColumns": [{"jsonPath": ".status.currentState.currentStateSummary", "name": "Current State", "type": "string"}, {"jsonPath": ".metadata.creationTimestamp", "name": "Age", "type": "date"}]' for f in $(ls ${SCRIPT_PATH}/../../../build/classes/java/main/META-INF/fabric8/*.spark.apache.org-v1.yml); do - yq -i '.spec.versions[0] += ({"additionalPrinterColumns": [{"jsonPath": ".status.currentState.currentStateSummary", "name": "Current State", "type": "string"}, {"jsonPath": ".metadata.creationTimestamp", "name": "Age", "type": "date"}]})' $f + yq -i ".spec.versions |= map (. + ({$printerColumns}))" $f done -