Git Product home page Git Product logo

oras-helm-demo's Introduction

oras-helm-demo

Demo of using oras as a Go library to push/pull a Helm chart to/from a registry.

Setup

Start a Distribution registry server at localhost:5000 with the following command:

docker run -dp 5000:5000 --restart=always --name registry registry:2

The will run in the background. Use docker logs -f registry to see the logs and docker rm -f registry to stop.

Examples

To run examples below, clone this repo and gather required dependencies (requires Go 1.11+):

git clone [email protected]:jdolitsky/oras-helm-demo.git && cd oras-helm-demo/
GO111MODULE=on go mod vendor

Push Helm chart to registry

Souce code for push.go can be found here.

Run push.go with 2 arguments:

go run push.go mychart/ localhost:5000/mychart:latest

The first arg, mychart/, refers to a Helm chart directory path.

The second arg, localhost:5000/mychart:latest is a reference to a remote registry address.

This will push the chart as 2 separate layers with the following media types:

  1. application/vnd.cncf.helm.chart.meta.v1+json (metadata)
  2. application/vnd.cncf.helm.chart.content.v1+tar (package content)

By separating Chart.yaml (a.k.a the metadata) from the rest of the Helm chart, we prevent storing the same content in the registry twice for different names.

Pull Helm chart from registry

Souce code for pull.go can be found here.

Run pull.go with a single argument:

go run pull.go localhost:5000/mychart:latest

This will download and convert the stored Helm chart into a usable format, saving it to ./output/<chartname>.

The Manifest

You can use curl and jq to inspect the manifest of a Helm chart stored in a registry:

curl -s -H 'Accept: application/vnd.oci.image.manifest.v1+json' \
    http://localhost:5000/v2/mychart/manifests/latest | jq

Example manifest:

{
  "schemaVersion": 2,
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2
  },
  "layers": [
    {
      "mediaType": "application/vnd.cncf.helm.chart.meta.v1+json",
      "digest": "sha256:c356ec641a696eb5f3320bed9e8ceeb505fcc84b7ee072a85a8098fc362e13b7",
      "size": 210,
      "annotations": {
        "org.opencontainers.image.title": "meta.json"
      }
    },
    {
      "mediaType": "application/vnd.cncf.helm.chart.content.v1+tar",
      "digest": "sha256:e5e50410addbc4d1aa16100e42e4eb99f2bb4b04157de130a528e6e5d8c71774",
      "size": 431,
      "annotations": {
        "chart.name": "mychart",
        "chart.version": "2.7.1",
        "org.opencontainers.image.title": "content.tgz"
      }
    }
  ]
}

oras-helm-demo's People

Contributors

jdolitsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.