Skip to content

Commit 05f2716

Browse files
committed
[SPARK-52251] Support generating both v1alpha1 and v1beta1 from CRD generator
### What changes were proposed in this pull request? This PR adds support to generate SparkApplication and SparkCluster CRD yaml with both v1alpha1 and v1beta1 version, with storage set to v1beta1. ### Why are the changes needed? With this patch, our gradle task would be able to generate yaml that matches latest changes in CRD POJO, and save us from maintaining the yaml files for new version. The similar pattern can be used when we promote to future (v1/v2 ...) versions. We may keep the previous version POJO in separate package, leaving them as a reference, and specify the storage version only to the latest. No ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? CIs. Also, validated the generated yaml includes both versions. ### Was this patch authored or co-authored using generative AI tooling? No
1 parent 93a27e3 commit 05f2716

File tree

4 files changed

+184
-0
lines changed

4 files changed

+184
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.spark.k8s.operator.v1alpha1;
21+
22+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
23+
import com.fasterxml.jackson.annotation.JsonInclude;
24+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
25+
import io.fabric8.kubernetes.model.annotation.Group;
26+
import io.fabric8.kubernetes.model.annotation.ShortNames;
27+
import io.fabric8.kubernetes.model.annotation.Version;
28+
29+
import org.apache.spark.k8s.operator.BaseResource;
30+
import org.apache.spark.k8s.operator.Constants;
31+
import org.apache.spark.k8s.operator.spec.ApplicationSpec;
32+
import org.apache.spark.k8s.operator.status.ApplicationAttemptSummary;
33+
import org.apache.spark.k8s.operator.status.ApplicationState;
34+
import org.apache.spark.k8s.operator.status.ApplicationStateSummary;
35+
import org.apache.spark.k8s.operator.status.ApplicationStatus;
36+
37+
@JsonInclude(JsonInclude.Include.NON_NULL)
38+
@JsonDeserialize()
39+
@Group(Constants.API_GROUP)
40+
@Version(value = "v1alpha1", storage = false)
41+
@ShortNames({"sparkapp"})
42+
@JsonIgnoreProperties(ignoreUnknown = true)
43+
public class SparkApplication
44+
extends BaseResource<
45+
ApplicationStateSummary,
46+
ApplicationAttemptSummary,
47+
ApplicationState,
48+
ApplicationSpec,
49+
ApplicationStatus> {
50+
@Override
51+
public ApplicationStatus initStatus() {
52+
return new ApplicationStatus();
53+
}
54+
55+
@Override
56+
public ApplicationSpec initSpec() {
57+
return new ApplicationSpec();
58+
}
59+
60+
public org.apache.spark.k8s.operator.SparkApplication asLatestSparkApplication() {
61+
org.apache.spark.k8s.operator.SparkApplication app =
62+
new org.apache.spark.k8s.operator.SparkApplication();
63+
app.setMetadata(getMetadata());
64+
app.setSpec(spec);
65+
app.setStatus(status);
66+
return app;
67+
}
68+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.spark.k8s.operator.v1alpha1;
21+
22+
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;
23+
import lombok.NoArgsConstructor;
24+
25+
@NoArgsConstructor
26+
public class SparkApplicationList extends DefaultKubernetesResourceList<SparkApplication> {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.spark.k8s.operator.v1alpha1;
21+
22+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
23+
import com.fasterxml.jackson.annotation.JsonInclude;
24+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
25+
import io.fabric8.kubernetes.model.annotation.Group;
26+
import io.fabric8.kubernetes.model.annotation.ShortNames;
27+
import io.fabric8.kubernetes.model.annotation.Version;
28+
29+
import org.apache.spark.k8s.operator.BaseResource;
30+
import org.apache.spark.k8s.operator.Constants;
31+
import org.apache.spark.k8s.operator.spec.ClusterSpec;
32+
import org.apache.spark.k8s.operator.status.ClusterAttemptSummary;
33+
import org.apache.spark.k8s.operator.status.ClusterState;
34+
import org.apache.spark.k8s.operator.status.ClusterStateSummary;
35+
import org.apache.spark.k8s.operator.status.ClusterStatus;
36+
37+
@JsonInclude(JsonInclude.Include.NON_NULL)
38+
@JsonDeserialize()
39+
@Group(Constants.API_GROUP)
40+
@Version(value = "v1alpha1", storage = false)
41+
@ShortNames({"sparkcluster"})
42+
@JsonIgnoreProperties(ignoreUnknown = true)
43+
public class SparkCluster
44+
extends BaseResource<
45+
ClusterStateSummary, ClusterAttemptSummary, ClusterState, ClusterSpec, ClusterStatus> {
46+
@Override
47+
public ClusterStatus initStatus() {
48+
return new ClusterStatus();
49+
}
50+
51+
@Override
52+
public ClusterSpec initSpec() {
53+
return new ClusterSpec();
54+
}
55+
56+
public org.apache.spark.k8s.operator.SparkCluster asLatestSparkCluster() {
57+
org.apache.spark.k8s.operator.SparkCluster cluster =
58+
new org.apache.spark.k8s.operator.SparkCluster();
59+
cluster.setMetadata(getMetadata());
60+
cluster.setSpec(spec);
61+
cluster.setStatus(status);
62+
return cluster;
63+
}
64+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.spark.k8s.operator.v1alpha1;
21+
22+
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;
23+
import lombok.NoArgsConstructor;
24+
25+
@NoArgsConstructor
26+
public class SparkClusterList extends DefaultKubernetesResourceList<SparkCluster> {}

0 commit comments

Comments
 (0)