GoogleCloudPlatform / cloud-builders-community

Community-contributed images for Google Cloud Build
https://cloud.google.com/cloud-build/
Apache License 2.0
1.26k stars 856 forks source link

Helm (built docker image) really heavy on cloud build pipeline and affect execution time #480

Open Emixam23-FCMS opened 3 years ago

Emixam23-FCMS commented 3 years ago

Affected builder image

gcr.io/cloud-builders-community/helm

The image built for helm to be used on cloud build is very (very) heavy, more than 3GB https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/helm

Expected Behavior

I would like the build to result to a smaller image so the cloud build step can execute faster (as the pull would be less significant)

Actual Behavior

The image built for helm to be used on cloud build is very (very) heavy, more than 3GB

sakulh commented 3 years ago

I have same problem. Due to big size of the Helm docker image the duration time of the deploy step is 00:01:37.

My deploy step in cloudbuild.yaml:

  - name: gcr.io/$_GOOGLE_CLOUD_PROJECT/helm
    id: Deploy chart
    args:
      - upgrade
      - -i
      - my-project
      - ./my-project-chart
      - -f
      - ./my-project-chart/values.yaml
    env:
      - KUBECONFIG=/workspace/.kube/config
      - TILLERLESS=true

I'am using Kaniko for building of the docker images and duration time is 5-10 seconds but deploy step is almost 2 minutes. Any idea how to speed up?

Thank you.

c4talyst commented 1 year ago

Ended up building a custom image for helm.

cloud-builders-community/helm: 1.1GB this image: 82.4MB

Dockerfile

FROM ubuntu:22.04

RUN apt update

RUN apt install -y \
    apt-transport-https \
    ca-certificates \
    gnupg \
    curl

RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
    | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
    | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

RUN curl https://baltocdn.com/helm/signing.asc \
    | gpg --dearmor | tee /usr/share/keyrings/helm.gpg > /dev/null
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" \
    | tee /etc/apt/sources.list.d/helm-stable-debian.list

RUN apt update
RUN apt install -y \
    helm \
    google-cloud-sdk-gke-gcloud-auth-plugin

cloudbuild.yaml

substitutions:
  _GCR_REGISTRY: eu.gcr.io
steps:
- name: gcr.io/cloud-builders/kubectl
  id: Configure kubectl
  args:
    - cluster-info
  env:
    - CLOUDSDK_COMPUTE_REGION=$_CUSTOM_REGION
    - CLOUDSDK_CONTAINER_CLUSTER=$_CUSTOM_CLUSTER
    - KUBECONFIG=/workspace/.kube/config
- name: $_GCR_REGISTRY/$PROJECT_ID/helm-ubuntu
  id: Helm upgrade whatever
  entrypoint: 'helm'
  args:
    - upgrade
    - -i
    - ... whatever ...
  env:
    - KUBECONFIG=/workspace/.kube/config
    - TILLERLESS=true