|
19 | 19 | set -ex |
20 | 20 | printenv |
21 | 21 |
|
22 | | -usage() { |
23 | | - echo "Usage: $0 [-p]" |
24 | | - echo " -p : Create a public cloud release." |
25 | | -} |
26 | | - |
27 | | -parse_args() { |
28 | | - while test $# -gt 0; do |
29 | | - case "$1" in |
30 | | - -p) PUBLIC=true |
31 | | - shift |
32 | | - ;; |
33 | | - *) usage ;; |
34 | | - esac |
35 | | - done |
36 | | -} |
37 | | - |
38 | | -parse_args "$@" |
39 | | - |
40 | 22 | artifacts_dir="${ARTIFACTS_DIR:?}" |
41 | 23 |
|
42 | 24 | repo_path=$(pwd) |
|
50 | 32 |
|
51 | 33 | echo "The image tag is: ${release_tag}" |
52 | 34 |
|
53 | | -# We are building the OSS images/YAMLs. In this case, we only want to push the images but not deploy the YAMLs. |
54 | | -if [[ "$PUBLIC" == "true" ]]; then |
55 | | - bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \ |
56 | | - --//k8s:build_type=public //k8s/cloud:cloud_images_push |
57 | | - |
58 | | - all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS" "--remote_download_outputs=toplevel") |
59 | | - all_licenses_path="$(bazel cquery "${all_licenses_opts[@]}" --output starlark --starlark:expr "target.files.to_list()[0].path" 2> /dev/null)" |
60 | | - bazel build "${all_licenses_opts[@]}" |
61 | | - |
62 | | - gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/${release_tag}.json" |
63 | | - if [[ "${release}" == "true" ]]; then |
64 | | - gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/latest.json" |
65 | | - fi |
66 | | - |
67 | | - # Write YAMLs + image paths to a tar file to support easy deployment. |
68 | | - mkdir -p "${repo_path}/pixie_cloud/yamls" |
69 | | - image_list_file="${repo_path}/pixie_cloud/cloud_image_list.txt" |
70 | | - |
71 | | - kustomize build "k8s/cloud_deps/public/" > "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" |
72 | | - kustomize build "k8s/cloud_deps/base/elastic/operator" > "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" |
73 | | - kustomize build "k8s/cloud/public/" > "${repo_path}/pixie_cloud/yamls/cloud.yaml" |
| 35 | +bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \ |
| 36 | + --//k8s:build_type=public //k8s/cloud:cloud_images_push |
74 | 37 |
|
75 | | - deploy_yamls=( |
76 | | - "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" |
77 | | - "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" |
78 | | - "${repo_path}/pixie_cloud/yamls/cloud.yaml" |
79 | | - ) |
| 38 | +all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS" "--remote_download_outputs=toplevel") |
| 39 | +all_licenses_path="$(bazel cquery "${all_licenses_opts[@]}" --output starlark --starlark:expr "target.files.to_list()[0].path" 2> /dev/null)" |
| 40 | +bazel build "${all_licenses_opts[@]}" |
80 | 41 |
|
81 | | - bazel run @com_github_mikefarah_yq_v4//:v4 -- '..|.image?|select(.|type == "!!str")' -o=json "${deploy_yamls[@]}" | sort | uniq > "${image_list_file}" |
| 42 | +gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/${release_tag}.json" |
| 43 | +if [[ "${release}" == "true" ]]; then |
| 44 | + gsutil cp "${all_licenses_path}" "gs://pixie-dev-public/oss-licenses/latest.json" |
| 45 | +fi |
82 | 46 |
|
83 | | - cd "${repo_path}" |
84 | | - tar -czvf "${repo_path}/pixie_cloud.tar.gz" "pixie_cloud" |
85 | | - gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${release_tag}/pixie_cloud.tar.gz" |
86 | | - if [[ "${release}" == "true" ]]; then |
87 | | - gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz" |
88 | | - fi |
| 47 | +# Write YAMLs + image paths to a tar file to support easy deployment. |
| 48 | +mkdir -p "${repo_path}/pixie_cloud/yamls" |
| 49 | +image_list_file="${repo_path}/pixie_cloud/cloud_image_list.txt" |
89 | 50 |
|
90 | | - sha256sum "${repo_path}/pixie_cloud.tar.gz" | awk '{print $1}' > sha |
91 | | - cp "${repo_path}/pixie_cloud.tar.gz" "${artifacts_dir}/pixie_cloud.tar.gz" |
92 | | - cp sha "${artifacts_dir}/pixie_cloud.tar.gz.sha256" |
| 51 | +kustomize build "k8s/cloud_deps/public/" > "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" |
| 52 | +kustomize build "k8s/cloud_deps/base/elastic/operator" > "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" |
| 53 | +kustomize build "k8s/cloud/public/" > "${repo_path}/pixie_cloud/yamls/cloud.yaml" |
93 | 54 |
|
94 | | - exit 0 |
95 | | -fi |
| 55 | +deploy_yamls=( |
| 56 | + "${repo_path}/pixie_cloud/yamls/cloud_deps.yaml" |
| 57 | + "${repo_path}/pixie_cloud/yamls/cloud_deps_elastic_operator.yaml" |
| 58 | + "${repo_path}/pixie_cloud/yamls/cloud.yaml" |
| 59 | +) |
96 | 60 |
|
97 | | -bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \ |
98 | | - --//k8s:build_type=proprietary //k8s/cloud:cloud_images_push |
| 61 | +bazel run @com_github_mikefarah_yq_v4//:v4 -- '..|.image?|select(.|type == "!!str")' -o=json "${deploy_yamls[@]}" | sort | uniq > "${image_list_file}" |
99 | 62 |
|
100 | | -yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_staging_cloud.yaml" |
| 63 | +cd "${repo_path}" |
| 64 | +tar -czvf "${repo_path}/pixie_cloud.tar.gz" "pixie_cloud" |
| 65 | +gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/${release_tag}/pixie_cloud.tar.gz" |
101 | 66 | if [[ "${release}" == "true" ]]; then |
102 | | - # Build prod YAMLs. |
103 | | - yaml_path="${repo_path}/bazel-bin/k8s/cloud/pixie_prod_cloud.yaml" |
104 | | - bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_prod_cloud |
105 | | -else |
106 | | - # Build staging YAMLs. |
107 | | - bazel build --config=stamp -c opt --//k8s:image_version="${release_tag}" //k8s/cloud:pixie_staging_cloud |
| 67 | + gsutil cp "${repo_path}/pixie_cloud.tar.gz" "gs://pixie-dev-public/cloud/latest/pixie_cloud.tar.gz" |
108 | 68 | fi |
109 | 69 |
|
110 | | -kubectl apply -f "$yaml_path" |
| 70 | +sha256sum "${repo_path}/pixie_cloud.tar.gz" | awk '{print $1}' > sha |
| 71 | +cp "${repo_path}/pixie_cloud.tar.gz" "${artifacts_dir}/pixie_cloud.tar.gz" |
| 72 | +cp sha "${artifacts_dir}/pixie_cloud.tar.gz.sha256" |
0 commit comments