-
Notifications
You must be signed in to change notification settings - Fork 13
selkies image streaming check #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deepak7093
wants to merge
11
commits into
selkies-project:master
Choose a base branch
from
deepak7093:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fce8a1f
selkies image streaming check
6151b35
GAR tagging
f1266a5
move docker script
fac8817
fix image tags
dc084c0
add artifat registry
367348e
artifact sa moved to core infra
66f693b
selkies copyright
0df8811
sa email ref
27ea0cb
Merge branch 'selkies-project:master' into master
deepak7093 ac95019
tf fmt,installer image
e2f045f
Merge branch 'selkies-project:master' into master
deepak7093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# Limitations of GKE image streaming | ||
# 1. You can't use a Secret to pull container images on GKE versions prior to 1.23.5-gke.1900. | ||
# 2. Container images that use the V2 Image Manifest, schema version 1 are not eligible. | ||
# 3. Container images encrypted with customer-managed encryption keys (CMEK) are not eligible for Image streaming. GKE downloads these images without streaming the data. You can still use CMEK to protect attached persistent disks and custom boot disks in clusters that use Image streaming. | ||
# 4. Container images with empty layers or duplicate layers are not eligible for Image streaming. GKE downloads these images without streaming the data. Check your container image for empty layers or duplicate layers. | ||
# 5. The Artifact Registry repository must be in the same region as your GKE nodes, or in a multi-region that corresponds with the region where your nodes are running. For example: | ||
# If your nodes are in us-east1, Image streaming is available for repositories in the us-east1 region or the us multi-region since both GKE and Artifact Registry are running in data center locations within the United States. | ||
# If your nodes are in the northamerica-northeast1 region, the nodes are running in Canada. In this situation, Image streaming is only available for repositories in the same region. | ||
# 6. If your workloads read many files in an image during initialization, you might notice increased initialization times because of the latency added by the remote file reads. | ||
# 7. You might not notice the benefits of Image streaming during the first pull of an eligible image. However, after Image streaming caches the image, future image pulls on any cluster benefit from Image streaming. | ||
# 8. GKE uses the cluster-level configuration to determine whether to enable Image streaming on new node pools created using node auto-provisioning. However, you cannot use workload separation to create node pools with Image streaming enabled when Image streaming is disabled at the cluster level. | ||
# 9. Linux file capabilities such as CAP_NET_RAW are supported with Image streaming in GKE version 1.22.6-gke.300 and later. For previous GKE versions, these capabilities are not available when the image file is streamed, or when the image is saved to the local disk. To avoid potential disruptions, do not use Image streaming for containers with these capabilities in GKE versions prior to 1.22.6-gke.300. If your container relies on Linux file capabilities, it might fail to start with permission denied errors when running with Image streaming enabled. | ||
set -ex | ||
display_usage() { | ||
|
||
echo -e "\nUsage: $0 -i \n" | ||
echo -e "Argument: \n" | ||
echo -e "\t -i: IMAGE_NAME" | ||
} | ||
if [ $# -le 1 ] | ||
then | ||
display_usage | ||
exit 1 | ||
fi | ||
|
||
while getopts i:h: flag | ||
do | ||
case "${flag}" in | ||
i) IMAGE=${OPTARG};; | ||
*) display_usage | ||
exit 1 ;; | ||
esac | ||
done | ||
|
||
# docker pull $IMAGE | ||
DOCKER_SCHEMA_VERSION=$(docker manifest inspect --verbose ${IMAGE} | grep '"schemaVersion": 2,' | wc -l) | ||
LAYERS=$(docker inspect $IMAGE | jq .[].RootFS.Layers | sort | wc -l) | ||
UNIQUE_LAYERS=$(docker inspect $IMAGE | jq .[].RootFS.Layers | sort | uniq | wc -l ) | ||
EMPTY_LAYER=$(docker inspect $IMAGE | jq .[].RootFS.Layers | grep -i "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" | wc -l) | ||
|
||
if [[ $DOCKER_SCHEMA_VERSION -eq 0 ]]; then | ||
echo "[ ERROR ] Image ${IMAGE} failed to match image streaming criteria. Reason: Docker schema version mismatch, reqires schemaVersion: 2" | ||
echo "[ ERROR ] schemaVersion : $(docker manifest inspect --verbose ${IMAGE} | grep '"schemaVersion"')" | ||
exit 1 | ||
fi | ||
|
||
if [[ $LAYERS -ne $UNIQUE_LAYERS ]]; then | ||
echo "[ ERROR ] Image ${IMAGE} failed to match image streaming criteria. Reason: Duplicate docker layers." | ||
echo "[ ERROR ] Duplicate layers: $(docker inspect $IMAGE | jq .[].RootFS.Layers | sort | uniq -d)" | ||
exit 1 | ||
fi | ||
|
||
if [[ $EMPTY_LAYER -gt 0 ]]; then | ||
echo "[ ERROR ] Image ${IMAGE} failed to match image streaming criteria. Reason: Empty docker layers." | ||
echo "[ ERROR ] Image contains empty layers with sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" | ||
deepak7093 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 1 | ||
fi | ||
|
||
echo "[ INFO ] Success!!! Image ${IMAGE} matching criteria for image streaming." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2022 The Selkies 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. | ||
resource "google_artifact_registry_repository" "selkies-repo" { | ||
provider = google-beta | ||
location = var.region | ||
repository_id = "selkies-images" | ||
description = "selkies image artifact registry" | ||
format = "DOCKER" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2022 The Selkies 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. | ||
|
||
timeout: 10800s | ||
substitutions: | ||
_ACTION: apply | ||
_NAME: broker | ||
_REGION: us-west1 | ||
_TIER3: "true" | ||
tags: | ||
- selkies-node-pool-image-streaming | ||
- selkies-image-streaming | ||
steps: | ||
### | ||
# Create GCS bucket to store terraform state | ||
### | ||
- name: "gcr.io/cloud-builders/gsutil" | ||
id: "create-tf-state-bucket" | ||
entrypoint: "/bin/bash" | ||
args: | ||
- "-xe" | ||
- "-c" | ||
- | | ||
gsutil mb gs://${PROJECT_ID}-${_NAME}-tf-state || true | ||
waitFor: ["-"] | ||
### | ||
# Copy terraform binary | ||
### | ||
- name: "hashicorp/terraform:1.2.0" | ||
id: "terraform-download" | ||
entrypoint: "/bin/sh" | ||
args: | ||
- "-exc" | ||
- | | ||
cp /bin/terraform /workspace/ | ||
waitFor: ["-"] | ||
|
||
### | ||
# Apply terraform to create base infrastructure | ||
### | ||
- name: "gcr.io/cloud-builders/gcloud" | ||
id: "terraform-apply" | ||
entrypoint: "/workspace/deploy.sh" | ||
env: | ||
- PATH=/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workspace | ||
- TF_VAR_project_id=${PROJECT_ID} | ||
- TF_VAR_name=${_NAME} | ||
- TF_VAR_region=${_REGION} | ||
- TF_VAR_tier3_pool_enabled=${_TIER3} | ||
- TERRAFORM_WORKSPACE_NAME=image-straming-${_REGION} | ||
- ACTION=${_ACTION} | ||
waitFor: ["terraform-download"] | ||
deepak7093 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.