Skip to content

Commit

Permalink
add helm chart and README
Browse files Browse the repository at this point in the history
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
  • Loading branch information
Adphi committed Nov 1, 2023
1 parent def32e8 commit 8e0aabd
Show file tree
Hide file tree
Showing 27 changed files with 1,136 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ tmp
bin
**/node_modules
**/build
docs
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ docker-push:
ifneq ($(TAG),)
@docker image push $(REPOSITORY)/$(PROJECT):latest
endif

.PHONY: cli-docs
cli-docs:
@rm -rf ./docs/{lkar,lkard}
@go run -tags=docs ./cmd/lkar docs ./docs/lkar
@go run -tags=docs ./cmd/lkard docs ./docs/lkard
133 changes: 133 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<p align="center">
<img alt="LK Artifact Registry" src="ui/src/img/lkar-no-background.png" width='720px'/>
</p>


# LK Artifact Registry

[![PkgGoDev](https://pkg.go.dev/badge/go.linka.cloud/artifact-registry)](https://pkg.go.dev/go.linka.cloud/artifact-registry)
[![Go Report Card](https://goreportcard.com/badge/go.linka.cloud/artifact-registry)](https://goreportcard.com/report/go.linka.cloud/artifact-registry)

*Distribute your artifacts to your end users without any additional administration or maintenance costs.*

Artifact Registry is a 100% stateless enterprise ready artifact registry.

It uses any compatible oci-registry as backend, for both storage, authentication and authorization, making it easy to deploy and maintain.

It can host as many repositories as you want, all being backed by a single oci-repository (docker image).

It has two main parts:
- lkard: the registry server which expose a small web-ui
- lkar: the command line client

## Packages formats

The following package formats are supported:

- deb
- rpm
- apk
- helm
- ... (more to come)

## Quick start (evaluation only)

Let's start by deploying a docker registry (without authentication), the artifact registry and an alpine based client to test it:

```yaml
version: '3.7'
services:
registry:
image: registry:2
artifact-registry:
container_name: artifact-registry
image: linkacloud/artifact-registry:dev
environment:
ARTIFACT_REGISTRY_AES_KEY: "noop"
command:
- --backend=registry:5000
- --no-https
ports:
- "9887:9887"
artifact-registry-client:
container_name: artifact-registry-client
image: linkacloud/artifact-registry:dev
init: true
entrypoint: ["/bin/sh", "-c"]
command:
- sleep infinity
```

```bash
curl https://raw.githubusercontent.com/linka-cloud/artifact-registry/main/docker-compose.yaml | docker compose -f - up -d
```

Now, let's get some packages:

```bash
docker exec -it artifact-registry-client sh -c "apk fetch --no-cache -o /tmp -R curl jq"
```

Upload them to the registry:

```bash
docker exec -it artifact-registry-client sh -c "find /tmp -name '*.apk' -exec lkar apk push --plain-http artifact-registry:9887/test v3.18 main {} \;"
# remove any existing apk repository and cache
docker exec -it artifact-registry-client sh -c "rm -rf /tmp/* && rm -rf /var/cache/apk/* && rm -rf /etc/apk/repositories"
```

Setup artifact-registry as repository:

```bash
docker exec -it artifact-registry-client sh -c "lkar apk setup --plain-http artifact-registry:9887/test v3.18 main"
```

And finally, install the packages:

```bash
docker exec -it artifact-registry-client sh -c "apk add --no-cache curl jq"
```


Clean up:

```bash
curl https://raw.githubusercontent.com/linka-cloud/artifact-registry/main/docker-compose.yaml | docker compose -f - down --volumes --remove-orphans
```

## Getting started

### Deploying the registry

Deploy the registry using helm:

```bash
helm repo add linka-cloud https://helm.linka.cloud

REGISTRY=registry.example.org

helm upgrade \
--install \
--create-namespace \
--namespace artifact-registry \
--set config.backend.host=$REGISTRY \
artifact-registry \
linka-cloud/artifact-registry
```

See the [values.yaml](./helm/artifact-registry/values.yaml) for the available configuration options.


<!--- ### Using the registry --->

<!--- TODO(adphi): add instructions for installing the client --->


<!--- TODO(adphi): add lkard and lkar usage --->


## Acknowledgements

This package formats implementations are based on the amazing work done of the [Gitea](https://gitea.io) team.

Many thanks to them for their work, especially to [@KN4CK3R](https://github.com/KN4CK3R).
45 changes: 45 additions & 0 deletions cmd/lkar/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//go:build docs

// Copyright 2023 Linka Cloud All rights reserved.
//
// 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.

package main

import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var docsCmd = &cobra.Command{
Use: "docs",
Short: "Generate documentation",
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := os.MkdirAll(args[0], 0755); err != nil {
return err
}
cmd.Root().DisableAutoGenTag = true
if err := doc.GenMarkdownTree(cmd.Root(), args[0]); err != nil {
return err
}
return nil
},
}

func init() {
rootCmd.AddCommand(docsCmd)
}
1 change: 1 addition & 0 deletions cmd/lkar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var (

rootCmd = &cobra.Command{
Use: "lkar",
Short: "An OCI based Artifact Registry",
SilenceUsage: true,
PersistentPreRunE: setup,
}
Expand Down
45 changes: 45 additions & 0 deletions cmd/lkard/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//go:build docs

// Copyright 2023 Linka Cloud All rights reserved.
//
// 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.

package main

import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var docsCmd = &cobra.Command{
Use: "docs",
Short: "Generate documentation",
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := os.MkdirAll(args[0], 0755); err != nil {
return err
}
cmd.Root().DisableAutoGenTag = true
if err := doc.GenMarkdownTree(cmd.Root(), args[0]); err != nil {
return err
}
return nil
},
}

func init() {
cmd.AddCommand(docsCmd)
}
3 changes: 2 additions & 1 deletion cmd/lkard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var (
debug bool

cmd = &cobra.Command{
Use: "artifact-registry (repository)",
Use: "lkard (repository)",
Short: "An OCI based Artifact Registry",
Args: cobra.MaximumNArgs(1),
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.7'
services:
registry:
image: registry:2
artifact-registry:
container_name: artifact-registry
image: linkacloud/artifact-registry:dev
environment:
ARTIFACT_REGISTRY_AES_KEY: "noop"
command:
- --backend=registry:5000
- --no-https
ports:
- "9887:9887"
artifact-registry-client:
container_name: artifact-registry-client
image: linkacloud/artifact-registry:dev
init: true
entrypoint: ["/bin/sh", "-c"]
command:
- sleep infinity
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1
github.com/klauspost/compress v1.16.5
github.com/lithammer/dedent v1.1.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc5
github.com/sassoftware/go-rpmutils v0.2.0
Expand Down Expand Up @@ -43,6 +44,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.7.6 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.5.0 // indirect
Expand Down Expand Up @@ -83,7 +85,6 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lithammer/dedent v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
Expand All @@ -105,6 +106,7 @@ require (
github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect
github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect
github.com/redis/go-redis/v9 v9.1.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG
github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
Expand Down Expand Up @@ -372,6 +373,7 @@ github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sassoftware/go-rpmutils v0.2.0 h1:pKW0HDYMFWQ5b4JQPiI3WI12hGsVoW0V8+GMoZiI/JE=
github.com/sassoftware/go-rpmutils v0.2.0/go.mod h1:TJJQYtLe/BeEmEjelI3b7xNZjzAukEkeWKmoakvaOoI=
Expand Down
23 changes: 23 additions & 0 deletions helm/artifact-registry/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions helm/artifact-registry/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: docker-registry
repository: https://helm.twun.io
version: 2.2.2
digest: sha256:be42beba50635bbb5361c016785d80e382c14604f2690afbebf8d297df745b7b
generated: "2023-10-17T16:04:51.57078+02:00"
32 changes: 32 additions & 0 deletions helm/artifact-registry/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v2
name: artifact-registry
description: A Helm chart for LK Artifact Registry
home: https://github.com/linka-cloud/artifact-registry

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.0.0"

dependencies:
- name: docker-registry
version: 2.2.2
repository: https://helm.twun.io
alias: registry
condition: registry.enabled
Loading

0 comments on commit 8e0aabd

Please sign in to comment.