Skip to content

Commit

Permalink
output registry address as output instead
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <[email protected]>
  • Loading branch information
tthvo committed Jun 6, 2024
1 parent a964db8 commit dfb7fe8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ jobs:
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Create kind cluster with registry
id: kind
uses: ./
with:
registry: true
registry_name: custom-registry
registry_port: 5001

- name: Test
env:
LOCAL_REGISTRY: ${{ steps.kind.outputs.LOCAL_REGISTRY }}
run: |
kubectl cluster-info
kubectl get storageclass standard
Expand All @@ -210,6 +213,7 @@ jobs:
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Create kind cluster with registry and delete enabled
id: kind
uses: ./
with:
registry: true
Expand All @@ -218,6 +222,8 @@ jobs:
registry_enable_delete: true

- name: Test
env:
LOCAL_REGISTRY: ${{ steps.kind.outputs.LOCAL_REGISTRY }}
run: |
kubectl cluster-info
kubectl get storageclass standard
Expand Down
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,27 @@ For more information on inputs, see the [API Documentation](https://developer.gi
- `install_only`: Skips cluster creation, only install kind (default: false)
- `ignore_failed_clean`: Whether to ignore the post delete cluster action failing (default: false)

## Configuring Local Registry
### Example Workflow

Create a workflow (eg: `.github/workflows/create-cluster.yml`):

```yaml
name: Create Cluster

on: pull_request

jobs:
create-cluster:
runs-on: ubuntu-latest
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
```
This uses [@helm/kind-action](https://github.com/helm/kind-action) GitHub Action to spin up a [kind](https://kind.sigs.k8s.io/) Kubernetes cluster on every Pull Request.
See [@helm/chart-testing-action](https://github.com/helm/chart-testing-action) for a more practical example.
### Configuring Local Registry
Create a workflow (eg: `.github/workflows/create-cluster-with-registry.yml`):

Expand All @@ -45,6 +65,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Kubernetes KinD Cluster
id: kind
uses: helm/kind-action@v1
with:
registry: true
Expand All @@ -53,7 +74,7 @@ jobs:
registry_enable_delete: true
```

This will configure the cluster with an insecure local registry at `my-registry:5001` on both the host and within cluster. Subsequent steps can refer to the registry address with the environment variable `LOCAL_REGISTRY` (i.e. `my-registry:5001`).
This will configure the cluster with an insecure local registry at `my-registry:5001` on both the host and within cluster. Subsequent steps can refer to the registry address with the output of the kind setup step (i.e. `${{ steps.kind.outputs.LOCAL_REGISTRY }}`).

**Note**: If `config` option is used, you must manually configure the cluster with registry config dir enabled at `/etc/containerd/certs.d`. For example:

Expand All @@ -66,26 +87,6 @@ containerdConfigPatches:
config_path = "/etc/containerd/certs.d"
```

### Example Workflow

Create a workflow (eg: `.github/workflows/create-cluster.yml`):

```yaml
name: Create Cluster
on: pull_request
jobs:
create-cluster:
runs-on: ubuntu-latest
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
```

This uses [@helm/kind-action](https://github.com/helm/kind-action) GitHub Action to spin up a [kind](https://kind.sigs.k8s.io/) Kubernetes cluster on every Pull Request.
See [@helm/chart-testing-action](https://github.com/helm/chart-testing-action) for a more practical example.

## Code of conduct

Participation in the Helm community is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).
4 changes: 2 additions & 2 deletions registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ create_registry() {
# Local registry is available at $registry_name:$registry_port
echo "127.0.0.1 $registry_name" | sudo tee -a /etc/hosts

# Export environment variable for subsequent steps
echo "LOCAL_REGISTRY=$registry_name:$registry_port" >> "$GITHUB_ENV"
# Write registry address to output for subsequent steps
echo "LOCAL_REGISTRY=$registry_name:$registry_port" >> "$GITHUB_OUTPUT"
}

connect_registry() {
Expand Down

0 comments on commit dfb7fe8

Please sign in to comment.