-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy path.gitlab-ci.yml
158 lines (147 loc) · 5.36 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
stages:
- Artifacts
- Cross-Cloud
- End-To-End
- Update-Dashboard
before_script:
- export BASE_URL=${BASE_URL:-$(echo $CI_PROJECT_URL | cut -d'/' -f1-3)}
- mkdir -p ./data ; touch ./data/empty.env
- for envfile in data/*env ; do source $envfile ; echo ----- $envfile ---- ; cat $envfile ; done
- export KUBECONFIG=$(pwd)/data/${CLOUD}/kubeconfig
- >
if [ -z "$CROSS_CLOUD_YML" ]; then
export CROSS_CLOUD_YML="https://raw.githubusercontent.com/CrossCloudCI/cncf-configuration/production/cross-cloud.yml"
else
export CROSS_CLOUD_YML="$CROSS_CLOUD_YML"
fi
- >
if [ "$BASE_URL" == "https://gitlab.cncf.ci" ]; then
export ENVIRONMENT="pd"
elif [ "$BASE_URL" == "https://gitlab.staging.cncf.ci" ]; then
export ENVIRONMENT="sg"
elif [ "$BASE_URL" == "https://gitlab.dev.cncf.ci" ]; then
export ENVIRONMENT="dv"
elif [ "$BASE_URL" == "https://gitlab.cidev.cncf.ci" ]; then
export ENVIRONMENT="ci"
else
echo "Environment unknown: $BASE_URL"
exit 1
fi
- >
if [ "$CI_JOB_NAME" == "Build-Source" ]; then
source /opt/local/etc/rvmrc ; source /opt/local/etc/profile.d/rvm.sh ; rvm install "ruby-2.6.3" ; rvm use ruby-2.6.3 ; cp -a /opt/local/dashboard /dashboard ; pushd /dashboard ; source /opt/local/.env ; ./bin/update_dashboard ; popd
elif [ "$CI_JOB_NAME" == "Dashboard" ]; then
source /opt/local/etc/rvmrc ; source /opt/local/etc/profile.d/rvm.sh ; rvm install "ruby-2.6.3" ; rvm use ruby-2.6.3 ; cp -a /opt/local/dashboard /dashboard ; pushd /dashboard ; source /opt/local/.env ; ./bin/update_dashboard ; popd
else
source /opt/local/alpine/etc/rvmrc ; source /opt/local/alpine/etc/profile.d/rvm.sh ; rvm install "ruby-2.6.3" ; rvm use ruby-2.6.3 ; cp -a /opt/local/dashboard /dashboard ; pushd /dashboard ; source /opt/local/.env ; ./bin/update_dashboard ; popd
fi
.build_source: &build_source
image: buildpack-deps:stretch
stage: Artifacts
variables:
# SOURCE
# ORG: MUST BE SET
# PROJECT: MUST BE SET
# PROJECT_ID: MUST BE SET
script:
- apt update && apt -y install jq
- >
if [ -z "${SOURCE}" ]; then
exit 0 #Should Show Skipped on Gitlab CI FIXME
elif [ "${DISABLE_SOURCE}" == "yes" ]; then
exit 0 #Should Show Skipped on Gitlab CI FIXME
else
PROJECT_JOB=$(curl --header "PRIVATE-TOKEN:${TOKEN}" "${BASE_URL}/api/v4/projects/14/pipelines/${SOURCE}/jobs?scope=success" | jq '.[] | select(.name=="container") | .id')
curl -s -o data/kubernetes.env -L "${BASE_URL}/kubernetes/kubernetes/-/jobs/${PROJECT_JOB}/artifacts/raw/release.env"
cat data/kubernetes.env
fi
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
untracked: true
expire_in: 5 weeks
paths:
- ./data
# Deploy Template used for Each Cloud
.kubernetes_deploy_template: &kubernetes_deploy_template
image: ${CI_REGISTRY}/cncf/cross-cloud/provisioning:$CI_COMMIT_REF_SLUG
stage: Cross-Cloud
variables:
CLOUD: MUST BE SET
script:
- >
if [ $CLOUD == "packet" ] && [ $CI_COMMIT_REF_NAME == "production" ] && [ $ARCH != "arm64" ]; then
echo "Write reserved node config"
cp /cncf/packet/packet_master_reservation /cncf/packet/modules/master/override.tf
cp /cncf/packet/packet_worker_reservation /cncf/packet/modules/worker/override.tf
else
echo "Skipping reservations"
fi
- >
if [ $ARCH == "arm64" ]; then
echo "Write arm64 config"
cp /cncf/packet/packet_arch_override /cncf/packet/override.tf
export TF_VAR_master_node_count=1
else
echo "Skipping arm configuration"
fi
- /cncf/provision.sh ${CLOUD}-deploy ${ARCH}${ENVIRONMENT}${DEPLOYMENT_SHA} s3 ${CLOUD}
artifacts:
when: always
expire_in: 4 weeks
paths:
- ./data/
# # E2E Template used for Per Cloud e2e Tests
# .k8s_e2e_template: &k8s_e2e_template
# image: ${CI_REGISTRY}/kubernetes/kubernetes/kubernetes-e2e:ci-v1-6-3.job.4793
# stage: cncf-e2e
# variables:
# CLOUD: MUST BE SET
# environment:
# name: MUST BE SET
# url: MUST BE SET
# script:
# - /kubernetes/e2e/run-conformance.sh
# Per Cloud Destroy Template only run when DESTROY_VAR is Set
.kubernetes_cloud_destroy_template: &kubernetes_cloud_destroy_template
image: ${CI_REGISTRY}/cncf/cross-cloud/provisioning:$CI_COMMIT_REF_SLUG
stage: Cross-Cloud
when: manual
variables:
CLOUD: MUST BE SET
script:
- >
if [ $CLOUD == "oci" ]; then
echo "Writing certs"
mkdir /cncf/keys
echo "$OCI_API_KEY" > /cncf/keys/oci_api_key.pem
echo "$OCI_API_PUB" > /cncf/keys/oci_api_key_pub.pem
else
echo "Skipping OCI Cloud Certs"
fi
- /cncf/provision.sh ${CLOUD}-destroy ${ARCH}${ENVIRONMENT}${DEPLOYMENT_SHA} s3 ${CLOUD}
# Build-Source VARs
Build-Source:
<<: *build_source
# Cloud Deploy VARs
Provisioning:
<<: *kubernetes_deploy_template
variables:
CLOUD: "${CLOUD}"
# # AWS E2E VARs
# aws_k8s_e2e:
# <<: *k8s_e2e_template
# variables:
# CLOUD: ${AWS_CLOUD}
# environment:
# name: ${AWS_CLOUD}-${CI_COMMIT_REF_SLUG}
# url: https://$CI_ENVIRONMENT_SLUG.demo.cncf.ci/
# AWS Destroy VARs
Kubernetes_destroy:
<<: *kubernetes_cloud_destroy_template
variables:
CLOUD: "${CLOUD}"
Dashboard:
image: crosscloudci/debian-docker
stage: Update-Dashboard
script:
- echo 'true'