Skip to content

Conversation

@mszostok
Copy link
Collaborator

@mszostok mszostok commented Sep 5, 2021

Description

Currently each Capact installation downloads 1GB. We can reduce that by preloading images into our environment. This PR adds option to "snapshots" images defined in our Helm Charts. As a result we can mount them to env:

capact env create k3d --volume="$PWD/capact-images.tar:/var/lib/rancher/k3s/agent/images/capact-images.tar" --wait 5m

We can also run this command on each release and add that to our assets on GitHub release.

Changes proposed in this pull request:

  • Add option to archive images from Capact Helm Charts
    # Archive images from the stable Capact Helm repository from version 0.5.0
    capact alpha archive-images helm --version 0.5.0 --output ./capact-images-0.5.0.tar
    # Archive images from  Helm Chart released from the the '0fbf562' commit on the main branch
    capact alpha archive-images helm --version 0.4.0-0fbf562 --helm-repo-url @latest > ./capact-images-0.4.0-0fbf562.tar
    # You can use gzip to save the image file and make the backup smaller.
    capact alpha archive-images helm --version 0.5.0 --output ./capact-images-0.5.0.tar.gz --compress gzip
    # You can pipe output to use custom gzip
    capact alpha archive-images helm --version 0.5.0 --output-stdout | gzip > myimage_latest.tar.gz
  • Add apoc plugin to Neo4j docker image, so internet connection is not needed on startup
  • Add option to print Info in status printer
    I decided to use dot:
    Screenshot 2021-09-05 at 21 14 55
    but if you think, that emoji is better, let me know: (for me additional padding would be required in this scenario)
    Screenshot 2021-09-05 at 21 15 01

Testing

gzip archive (1.3G, create env time: 2m19s):

# custom, takes > 8min
capact alpha archive-images helm --version @latest --helm-repo-url https://storage.googleapis.com/capact-exp-helm-charts --output-stdout| gzip > ./archive.gzip.tar.gz

# our, takes > 8min
capact alpha archive-images helm -v --version @latest --helm-repo-url https://storage.googleapis.com/capact-exp-helm-charts --output ./archive.gzip.tar.gz --compress gzip

capact env create k3d -v --volume="$PWD/archive.gzip.tar.gz:/var/lib/rancher/k3s/agent/images/archive.gzip.tar.gz" --wait 5m

tar archive (3.6G, create env time: 2m30s):

capact alpha archive-images helm -v --version @latest --helm-repo-url https://storage.googleapis.com/capact-exp-helm-charts --output ./archive.tar

capact env create k3d -v --volume="$PWD/archive.tar:/var/lib/rancher/k3s/agent/images/archive.tar" --wait 5m

You can chekc that no images were pulled during capact install. The images that were pulled are directly connected with the k3d. We can in the future add option to cache also cluster images.

▲ kubectl get events -A | grep Pulling
kube-system     4m59s       Normal    Pulling                   pod/local-path-provisioner-5ff76fc89d-jbkkj                                                                                    Pulling image "rancher/local-path-provisioner:v0.0.19"
kube-system     4m59s       Normal    Pulling                   pod/coredns-854c77959c-s4qsf                                                                                                   Pulling image "rancher/coredns-coredns:1.8.0"
kube-system     4m59s       Normal    Pulling                   pod/metrics-server-86cbb8457f-4hz7l                                                                                            Pulling image "rancher/metrics-server:v0.3.6"
kube-system     4m39s       Normal    Pulling                   pod/helper-pod-create-pvc-ca9a5825-2edb-4620-8bfd-da843a725413                                                                 Pulling image "rancher/library-busybox:1.32.1"

Real dev scenario

  1. Save images without monitoring:

    capact alpha archive-images helm -v --version @latest --helm-repo-url https://storage.googleapis.com/capact-exp-helm-charts --output ./archive.tar --save-component=neo4j,ingress-nginx,argo,cert-manager,kubed,capact
  2. Create a cluster:

    #!/usr/bin/env bash
    
    readonly CURRENT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
    
    export DISABLE_MONITORING_INSTALLATION=true
    export ENABLE_POPULATOR=true
    export CLUSTER_TYPE=k3d
    export K3D_IMAGES_ARCHIVE="${CURRENT_DIR}/archive.tar"
    
    make dev-cluster

    Now it takes ~5min to have up and running Capact dev cluster.

Related issue(s)

@mszostok mszostok added enhancement New feature or request WIP Work in progress area/cli Relates to CLI labels Sep 5, 2021
@mszostok mszostok changed the title Archive images Add option to archive images from Capact Helm Charts, make neo4j internetless Sep 5, 2021
@mszostok mszostok changed the title Add option to archive images from Capact Helm Charts, make neo4j internetless Add option to archive images from Capact Helm Charts, make neo4j "internetless" Sep 5, 2021
@mszostok mszostok force-pushed the archive-images branch 6 times, most recently from 6235a92 to 9065e32 Compare September 7, 2021 21:07
@mszostok mszostok removed the WIP Work in progress label Sep 9, 2021
@Trojan295 Trojan295 self-assigned this Sep 9, 2021
@mszostok mszostok merged commit b7bb7f2 into capactio:main Sep 9, 2021
@mszostok mszostok deleted the archive-images branch September 9, 2021 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Relates to CLI enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants