Skip to content

Commit

Permalink
Add license to generated manifest files
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Chen <[email protected]>
  • Loading branch information
ChenYi015 committed Feb 14, 2025
1 parent 0623c20 commit 7dc781c
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 19 deletions.
39 changes: 28 additions & 11 deletions hack/sync-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ echo "Syncing Kustomize manifests from manifests templated by trainer Helm chart
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

# Helm chart release name and namespace.
TRAINER_CHART_DIR=charts/trainer
Expand All @@ -41,7 +40,9 @@ DST_RUNTIMES_DIR=manifests/base/runtimes

MANIFESTS_FILE=$(mktemp -t kubeflow-trainer-manifests.yaml)
FIND_EXCLUDE_ARGS="-not -name kustomization.yaml -not -name kustomization.yml"
YQ_ARGS='.metadata.labels."app.kubernetes.io/managed-by" = "Kustomize" | del(.metadata.labels."helm.sh/chart")'
YEAR=$(date +%Y)
LICENSE=$(cat hack/boilerplate/boilerplate.go.txt | sed 's|//|#|' | sed "s|YEAR|${YEAR}|g")
YQ_ARGS=".metadata.labels.\"app.kubernetes.io/managed-by\" = \"Kustomize\" | del(.metadata.labels.\"helm.sh/chart\") | ... comments=\"\""

setup() {
# yq is required to parse yaml files.
Expand All @@ -63,24 +64,40 @@ update_crds() {
}

update_rbac() {
yq -e "select(.kind == \"ServiceAccount\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_RBAC_DIR}/serviceaccount.yaml
yq -e "select(.kind == \"ClusterRole\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_RBAC_DIR}/clusterrole.yaml
yq -e "select(.kind == \"ClusterRoleBinding\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_RBAC_DIR}/clusterrolebinding.yaml
yq -e "select(.kind == \"Role\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_RBAC_DIR}/role.yaml
yq -e "select(.kind == \"RoleBinding\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_RBAC_DIR}/rolebinding.yaml
printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RBAC_DIR}/serviceaccount.yaml
yq -e "select(.kind == \"ServiceAccount\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_RBAC_DIR}/serviceaccount.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RBAC_DIR}/clusterrole.yaml
yq -e "select(.kind == \"ClusterRole\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_RBAC_DIR}/clusterrole.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RBAC_DIR}/clusterrolebinding.yaml
yq -e "select(.kind == \"ClusterRoleBinding\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_RBAC_DIR}/clusterrolebinding.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RBAC_DIR}/role.yaml
yq -e "select(.kind == \"Role\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_RBAC_DIR}/role.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RBAC_DIR}/rolebinding.yaml
yq -e "select(.kind == \"RoleBinding\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_RBAC_DIR}/rolebinding.yaml
}

update_controller() {
yq -e "select(.kind == \"Deployment\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_CONTROLLER_DIR}/deployment.yaml
yq -e "select(.kind == \"Service\" and .metadata.name == \"kubeflow-trainer-controller-service\" | ${YQ_ARGS})" "${MANIFESTS_FILE}" > ${DST_CONTROLLER_DIR}/service.yaml
printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_CONTROLLER_DIR}/deployment.yaml
yq -e "select(.kind == \"Deployment\" and .metadata.name == \"kubeflow-trainer-controller\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_CONTROLLER_DIR}/deployment.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_CONTROLLER_DIR}/service.yaml
yq -e "select(.kind == \"Service\" and .metadata.name == \"kubeflow-trainer-controller-service\" | ${YQ_ARGS})" "${MANIFESTS_FILE}" >> ${DST_CONTROLLER_DIR}/service.yaml
}

update_webhook() {
yq -e "select(.kind == \"Secret\" and .metadata.name == \"kubeflow-trainer-webhook-cert\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" > ${DST_WEBHOOK_DIR}/secret.yaml
yq -e "select(.kind == \"ValidatingWebhookConfiguration\" and .metadata.name == \"kubeflow-trainer-validating-webhook\" | ${YQ_ARGS})" "${MANIFESTS_FILE}" > ${DST_WEBHOOK_DIR}/validatingwebhookconfiguration.yaml
printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_WEBHOOK_DIR}/secret.yaml
yq -e "select(.kind == \"Secret\" and .metadata.name == \"kubeflow-trainer-webhook-cert\") | ${YQ_ARGS}" "${MANIFESTS_FILE}" >> ${DST_WEBHOOK_DIR}/secret.yaml

printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_WEBHOOK_DIR}/validatingwebhookconfiguration.yaml
yq -e "select(.kind == \"ValidatingWebhookConfiguration\" and .metadata.name == \"kubeflow-trainer-validating-webhook\" | ${YQ_ARGS})" "${MANIFESTS_FILE}" >> ${DST_WEBHOOK_DIR}/validatingwebhookconfiguration.yaml
}

update_runtimes() {
printf '#\n%s\n#\n\n' "${LICENSE}" > ${DST_RUNTIMES_DIR}/pretraining/torch-distributed.yaml
yq -e "select(.kind == \"ClusterTrainingRuntime\" and .metadata.name == \"torch-distributed\")" "${MANIFESTS_FILE}" > ${DST_RUNTIMES_DIR}/pretraining/torch-distributed.yaml
}

Expand Down
17 changes: 16 additions & 1 deletion manifests/base/controller/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/controller/deployment.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
16 changes: 16 additions & 0 deletions manifests/base/controller/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

# Source: kubeflow-trainer/templates/controller/service.yaml
apiVersion: v1
kind: Service
Expand Down
17 changes: 16 additions & 1 deletion manifests/base/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/rbac/clusterrole.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down
17 changes: 16 additions & 1 deletion manifests/base/rbac/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/rbac/clusterrolebinding.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down
16 changes: 16 additions & 0 deletions manifests/base/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow authors.
#
# Licensed 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
#
# https://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.
#

resources:
- serviceaccount.yaml
- clusterrole.yaml
Expand Down
17 changes: 16 additions & 1 deletion manifests/base/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/rbac/role.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand Down
17 changes: 16 additions & 1 deletion manifests/base/rbac/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/rbac/rolebinding.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand Down
18 changes: 16 additions & 2 deletions manifests/base/rbac/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
---
# Source: kubeflow-trainer/templates/rbac/serviceaccount.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
17 changes: 16 additions & 1 deletion manifests/base/webhook/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Source: kubeflow-trainer/templates/webhook/secret.yaml
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

apiVersion: v1
kind: Secret
metadata:
Expand Down
16 changes: 16 additions & 0 deletions manifests/base/webhook/validatingwebhookconfiguration.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow Authors
#
# Licensed 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.
#

# Source: kubeflow-trainer/templates/webhook/validatingwebhookconfiguration.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down
16 changes: 16 additions & 0 deletions manifests/overlays/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow authors.
#
# Licensed 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
#
# https://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.
#

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

Expand Down
16 changes: 16 additions & 0 deletions manifests/overlays/manager/namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow authors.
#
# Licensed 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
#
# https://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.
#

apiVersion: v1
kind: Namespace
metadata:
Expand Down
16 changes: 16 additions & 0 deletions manifests/overlays/runtimes/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2024 The Kubeflow authors.
#
# Licensed 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
#
# https://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.
#

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
Expand Down

0 comments on commit 7dc781c

Please sign in to comment.