Pre-Populated Docker Cache #160723
Replies: 3 comments 7 replies
-
|
Hi @harshaisgud, thanks for this process. I'm trying to reproduce your setup but the PVC created from the volumeClaimTemplates doesn't contain anything while a manually created PVC using the the snapshot as a datasource works fine. I guess something is wrong with the EBS CSI controller somewhere. |
Beta Was this translation helpful? Give feedback.
-
|
I'm trying a slightly different approach where I'm hoping to use the existing runners to create the snapshot like so in a github workflow: With the snapshot id from that workflow run, I can populate the following resources: That all seems to work; however, there must be some sort of issue with the snapshot itself: In my workflows that use docker (for service containers for example), they're currently throwing this error: I'll update this comment if I find the resolution edit: issues resolved (see comment) |
Beta Was this translation helpful? Give feedback.
-
|
To build custom runner with Docker images cache you can add the following to original repo fork
#!/bin/bash -e
################################################################################
## File: configure-docker.sh
## Desc: Configure Docker
################################################################################
if [[ -z $DOCKERHUB_LOGIN || -z $DOCKERHUB_PAT ]]; then
echo No Docker Hub credentials provided
else
DOCKERHUB_CREDENTIALS_PROVIDED=true
fi
# Remove surrounding quotes
DOCKERHUB_IMAGES="${DOCKERHUB_IMAGES%\'}"
DOCKERHUB_IMAGES="${DOCKERHUB_IMAGES#\'}"
# Cache images of provided tags
DOCKERHUB_IMAGES=($DOCKERHUB_IMAGES)
LENGTH=${#DOCKERHUB_IMAGES[@]}
if (( $LENGTH > 0 )); then
if [[ -v DOCKERHUB_CREDENTIALS_PROVIDED ]]; then
echo $DOCKERHUB_PAT | docker login --username $DOCKERHUB_LOGIN --password-stdin
echo $DOCKERHUB_PAT | docker login --username $DOCKERHUB_LOGIN --password-stdin dhi.io
fi
echo "$LENGTH image tags provided"
for image in ${DOCKERHUB_IMAGES[@]}; do
docker pull $image
done
if [[ -v DOCKERHUB_CREDENTIALS_PROVIDED ]]; then
docker logout
docker logout dhi.io
fi
else
echo No image tags provided. Skip caching
fi
docker image list --format table
df --human-readable --type=ext4Add step after provisioner "shell" {
environment_vars = [
"DOCKERHUB_IMAGES='${var.dockerhub_images}'",
"DOCKERHUB_LOGIN=${var.dockerhub_login}",
"DOCKERHUB_PAT=${var.dockerhub_pat}",
"INSTALLER_SCRIPT_FOLDER=${local.installer_script_folder}"
]
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'"
script = "${path.root}/../scripts/build/configure-docker.sh"
}Define variables in variable "dockerhub_images" {
default = null
type = string
}
variable "dockerhub_login" {
sensitive = true
type = string
}
variable "dockerhub_pat" {
sensitive = true
type = string
}Provide variables during build PKR_VAR_dockerhub_images="$DOCKERHUB_IMAGES"
PKR_VAR_dockerhub_login=$DOCKERHUB_LOGIN
PKR_VAR_dockerhub_pat="$DOCKERHUB_PAT"Add variables and parameters to your pipeline parameters:
- name: dockerImagesToCache
default: none
displayName: Space separated list of Docker Hub image tags to cache
type: string
- job: Build Azure Pipeline Agent
...
variables:
- group: agent-builder-dockerhub-auth
- name: DOCKERHUB_IMAGES
readonly: true
${{ if ne(parameters.dockerImagesToCache, 'none') }}:
value: ${{ parameters.dockerImagesToCache }}Provide list of Docker Hub images to cache during Pipeline Agent build, e.g. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The process to setup a docker cache described in the repository does not satisfy my orgs requirement.
I have also followed the discussions extensively and found a few interesting approaches like actions/actions-runner-controller#1286 (comment)
Requirements for docker cache
Listed Steps have been performed on EKS(1.23) but they should work with any Kubernetes flavour implementing the CSI spec such as GKE.
Pre-requisites
Please refer the following documentation for
Once the pre-requisites have been satisfied run the following steps.
RetentionPolicyset to Delete.VolumeClaimTemplatesection such that volumes are populated from a snapshot.I am sure this can be made much more elegant and I am open to suggestions 😄
Beta Was this translation helpful? Give feedback.
All reactions