Skip to content

Commit 99c4f90

Browse files
committed
Add Azure AKS job
1 parent e536cc1 commit 99c4f90

File tree

5 files changed

+266
-4
lines changed

5 files changed

+266
-4
lines changed

.github/workflows/publish-all-operators.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ jobs:
169169
pattern: gcp-oidc-enclave-ids-*
170170
path: ./manifests/gcp_oidc_operator
171171

172-
- name: Download Azure manifest
172+
- name: Download Azure CC manifest
173173
uses: actions/download-artifact@v4
174174
with:
175175
pattern: azure-cc-enclave-id-*
176176
path: ./manifests/azure_cc_operator
177177

178+
- name: Download Azure AKS manifest
179+
uses: actions/download-artifact@v4
180+
with:
181+
pattern: azure-aks-enclave-id-*
182+
path: ./manifests/azure_aks_operator
183+
178184
- name: Download EIF manifest
179185
uses: actions/download-artifact@v4
180186
with:
@@ -217,6 +223,7 @@ jobs:
217223
(cd ./deployment/aws-euid-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../aws-euid-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
218224
(cd ./deployment/aws-uid2-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../aws-uid2-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
219225
(cd ./deployment/azure-cc-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../azure-cc-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
226+
(cd ./deployment/azure-aks-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../azure-aks-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
220227
(cd ./deployment/gcp-oidc-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../gcp-oidc-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
221228
(cd manifests && zip -r ../uid2-operator-release-manifests-${{ needs.start.outputs.new_version }}.zip .)
222229
@@ -230,6 +237,7 @@ jobs:
230237
./aws-euid-deployment-files-${{ needs.start.outputs.new_version }}.zip
231238
./aws-uid2-deployment-files-${{ needs.start.outputs.new_version }}.zip
232239
./azure-cc-deployment-files-${{ needs.start.outputs.new_version }}.zip
240+
./azure-aks-deployment-files-${{ needs.start.outputs.new_version }}.zip
233241
./gcp-oidc-deployment-files-${{ needs.start.outputs.new_version }}.zip
234242
./uid2-operator-release-manifests-${{ needs.start.outputs.new_version }}.zip
235243
notifyFailure:

.github/workflows/publish-azure-cc-enclave-docker.yaml

+51-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
IMAGE_VERSION=${{ steps.update_version.outputs.new_version }}
164164
165165
azureCc:
166-
name: Azure CC
166+
name: Create Azure CC artifacts
167167
runs-on: ubuntu-latest
168168
permissions: {}
169169
needs: buildImage
@@ -201,11 +201,59 @@ jobs:
201201
path: ${{ env.MANIFEST_OUTPUT_DIR }}
202202
if-no-files-found: error
203203

204-
e2e:
205-
name: E2E
204+
e2eAzureCc:
205+
name: E2E Azure CC
206206
uses: ./.github/workflows/run-e2e-tests-on-operator.yaml
207207
needs: [buildImage, azureCc]
208208
with:
209209
operator_type: azure
210210
operator_image_version: ${{ needs.buildImage.outputs.image_tag }}
211211
secrets: inherit
212+
213+
azureAks:
214+
name: Create Azure AKS artifacts
215+
runs-on: ubuntu-latest
216+
permissions: {}
217+
needs: buildImage
218+
steps:
219+
- name: Checkout
220+
uses: actions/checkout@v4
221+
222+
- name: Install Azure CLI
223+
uses: ./.github/actions/install_az_cli
224+
225+
- name: check azure-cli version
226+
run: |
227+
az --version
228+
229+
- name: Generate Azure deployment artifacts
230+
env:
231+
IMAGE: ${{ needs.buildImage.outputs.tags }}
232+
OUTPUT_DIR: ${{ env.ARTIFACTS_OUTPUT_DIR }}
233+
MANIFEST_DIR: ${{ env.MANIFEST_OUTPUT_DIR }}
234+
VERSION_NUMBER: ${{ needs.buildImage.outputs.jar_version }}
235+
run: |
236+
bash ./scripts/azure-aks/deployment/generate-deployment-artifacts.sh
237+
238+
- name: Upload deployment artifacts
239+
uses: actions/upload-artifact@v4
240+
with:
241+
name: azure-aks-deployment-files-${{ needs.buildImage.outputs.jar_version }}
242+
path: ${{ env.ARTIFACTS_OUTPUT_DIR }}
243+
if-no-files-found: error
244+
245+
- name: Upload manifest
246+
uses: actions/upload-artifact@v4
247+
with:
248+
name: azure-aks-enclave-id-${{ needs.buildImage.outputs.jar_version }}
249+
path: ${{ env.MANIFEST_OUTPUT_DIR }}
250+
if-no-files-found: error
251+
252+
e2eAzureAks:
253+
name: E2E Azure AKS
254+
uses: ./.github/workflows/run-e2e-tests-on-operator.yaml
255+
needs: [buildImage, azureAks]
256+
with:
257+
operator_type: aks
258+
operator_image_version: ${{ needs.buildImage.outputs.image_tag }}
259+
secrets: inherit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
# Following environment variables must be set
5+
# - IMAGE: uid2-operator image
6+
# - OUTPUT_DIR: output directory to store the artifacts
7+
# - MANIFEST_DIR: output directory to store the manifest for the enclave Id
8+
# - VERSION_NUMBER: the version number of the build
9+
10+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
11+
INPUT_DIR=${SCRIPT_DIR}
12+
13+
if [[ -z ${IMAGE} ]]; then
14+
echo "IMAGE cannot be empty"
15+
exit 1
16+
fi
17+
IMAGE_VERSION=$(echo $IMAGE | awk -F':' '{print $2}')
18+
if [[ -z ${IMAGE_VERSION} ]]; then
19+
echo "Failed to extract image version from ${IMAGE}"
20+
exit 1
21+
fi
22+
23+
if [[ -z ${OUTPUT_DIR} ]]; then
24+
echo "OUTPUT_DIR cannot be empty"
25+
exit 1
26+
fi
27+
28+
mkdir -p ${OUTPUT_DIR}
29+
if [[ $? -ne 0 ]]; then
30+
echo "Failed to create ${OUTPUT_DIR}"
31+
exit 1
32+
fi
33+
34+
mkdir -p ${MANIFEST_DIR}
35+
if [[ $? -ne 0 ]]; then
36+
echo "Failed to create ${MANIFEST_DIR}"
37+
exit 1
38+
fi
39+
40+
# Input files
41+
INPUT_FILES=(
42+
operator.yaml
43+
)
44+
45+
# Copy input files to output dir
46+
for f in ${INPUT_FILES[@]}; do
47+
cp ${INPUT_DIR}/${f} ${OUTPUT_DIR}/${f}
48+
if [[ $? -ne 0 ]]; then
49+
echo "Failed to copy ${INPUT_DIR}/${f} to ${OUTPUT_DIR}"
50+
exit 1
51+
fi
52+
done
53+
54+
az version
55+
# Install confcom extension, az is originally available in GitHub workflow environment
56+
az extension add --name confcom
57+
if [[ $? -ne 0 ]]; then
58+
echo "Failed to install Azure confcom extension"
59+
exit 1
60+
fi
61+
62+
# Required by az confcom
63+
sudo usermod -aG docker ${USER}
64+
if [[ $? -ne 0 ]]; then
65+
echo "Failed to add current user to docker group"
66+
exit 1
67+
fi
68+
69+
# Generate operator template
70+
sed -i "s#IMAGE_PLACEHOLDER#${IMAGE}#g" ${OUTPUT_DIR}/operator.yaml
71+
# && \
72+
# sed -i "s#IMAGE_VERSION_PLACEHOLDER#${IMAGE_VERSION}#g" ${OUTPUT_DIR}/operator.yaml
73+
if [[ $? -ne 0 ]]; then
74+
echo "Failed to pre-process operator template file"
75+
exit 1
76+
fi
77+
78+
# Export the policy, update it to turn off allow_environment_variable_dropping, and then insert it into the template
79+
# note that the EnclaveId is generated by generate.py on the raw policy, not the base64 version
80+
POLICY_DIGEST_FILE=azure-aks-operator-digest-$VERSION_NUMBER.txt
81+
az confcom acipolicygen --virtual-node-yaml ${OUTPUT_DIR}/operator.yaml --print-policy > ${INPUT_DIR}/policy.base64
82+
if [[ $? -ne 0 ]]; then
83+
echo "Failed to generate ACI policy"
84+
exit 1
85+
fi
86+
87+
base64 -di < ${INPUT_DIR}/policy.base64 > ${INPUT_DIR}/generated.rego
88+
sed -i "s#allow_environment_variable_dropping := true#allow_environment_variable_dropping := false#g" ${INPUT_DIR}/generated.rego
89+
sed -i 's#{"pattern":"DEPLOYMENT_ENVIRONMENT=DEPLOYMENT_ENVIRONMENT_PLACEHOLDER","required":false,"strategy":"string"}#{"pattern":"DEPLOYMENT_ENVIRONMENT=.+","required":false,"strategy":"re2"}#g' generated.rego
90+
sed -i 's#{"pattern":"VAULT_NAME=VAULT_NAME_PLACEHOLDER","required":false,"strategy":"string"}#{"pattern":"VAULT_NAME=.+","required":false,"strategy":"re2"}#g' generated.rego
91+
sed -i 's#{"pattern":"OPERATOR_KEY_SECRET_NAME=OPERATOR_KEY_SECRET_NAME_PLACEHOLDER","required":false,"strategy":"string"}#{"pattern":"OPERATOR_KEY_SECRET_NAME=.+","required":false,"strategy":"re2"}#g' generated.rego
92+
base64 -w0 < ${INPUT_DIR}/generated.rego > ${INPUT_DIR}/generated.rego.base64
93+
python3 ${SCRIPT_DIR}/generate.py ${INPUT_DIR}/generated.rego > ${MANIFEST_DIR}/${POLICY_DIGEST_FILE}
94+
95+
sed -i "s#CCE_POLICY_PLACEHOLDER#$(cat ${INPUT_DIR}/generated.rego.base64)#g" ${OUTPUT_DIR}/operator.yaml
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
from hashlib import sha256
3+
4+
def str_to_sha256(x: str) -> str:
5+
return sha256(x.encode('utf-8')).hexdigest()
6+
7+
def print_data_sha256(data: str) -> str:
8+
print(str_to_sha256(data))
9+
10+
def print_data_sha256_stripped(data: str) -> str:
11+
print(str_to_sha256(data.strip()))
12+
13+
def main():
14+
with open(sys.argv[1], 'r') as file:
15+
data = file.read()
16+
17+
print_data_sha256(data)
18+
19+
if __name__ == '__main__':
20+
main()
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: operator-deployment
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app.kubernetes.io/name: operator
10+
template:
11+
metadata:
12+
labels:
13+
app.kubernetes.io/name: operator
14+
annotations:
15+
microsoft.containerinstance.virtualnode.ccepolicy: CCE_POLICY_PLACEHOLDER
16+
microsoft.containerinstance.virtualnode.identity: IDENTITY_PLACEHOLDER
17+
microsoft.containerinstance.virtualnode.injectdns: "false"
18+
spec:
19+
containers:
20+
- image: "mcr.microsoft.com/aci/skr:2.7"
21+
imagePullPolicy: Always
22+
name: skr
23+
resources:
24+
limits:
25+
cpu: 2250m
26+
memory: 2256Mi
27+
requests:
28+
cpu: 100m
29+
memory: 512Mi
30+
env:
31+
- name: Port
32+
value: "9000"
33+
volumeMounts:
34+
- mountPath: /opt/confidential-containers/share/kata-containers/reference-info-base64
35+
name: endorsement-location
36+
command:
37+
- /skr.sh
38+
- name: uid2-operator
39+
image: IMAGE_PLACEHOLDER
40+
resources:
41+
limits:
42+
memory: "8Gi"
43+
imagePullPolicy: Always
44+
securityContext:
45+
runAsUser: 1000
46+
env:
47+
- name: VAULT_NAME
48+
value: VAULT_NAME_PLACEHOLDER
49+
- name: OPERATOR_KEY_SECRET_NAME
50+
value: OPERATOR_KEY_SECRET_NAME_PLACEHOLDER
51+
- name: DEPLOYMENT_ENVIRONMENT
52+
value: DEPLOYMENT_ENVIRONMENT_PLACEHOLDER
53+
ports:
54+
- containerPort: 8080
55+
protocol: TCP
56+
- name: prometheus
57+
containerPort: 9080
58+
protocol: TCP
59+
readinessProbe:
60+
failureThreshold: 3
61+
httpGet:
62+
path: /ops/healthcheck
63+
port: 8080
64+
scheme: HTTP
65+
initialDelaySeconds: 30
66+
periodSeconds: 10
67+
successThreshold: 1
68+
timeoutSeconds: 1
69+
volumes:
70+
- name: endorsement-location
71+
hostPath:
72+
path: /opt/confidential-containers/share/kata-containers/reference-info-base64
73+
nodeSelector:
74+
virtualization: virtualnode2
75+
tolerations:
76+
- effect: NoSchedule
77+
key: virtual-kubelet.io/provider
78+
operator: Exists
79+
---
80+
apiVersion: v1
81+
kind: Service
82+
metadata:
83+
name: operator-svc
84+
spec:
85+
type: LoadBalancer
86+
selector:
87+
app.kubernetes.io/name: operator
88+
ports:
89+
- protocol: TCP
90+
port: 80
91+
targetPort: 8080

0 commit comments

Comments
 (0)