When building local images with docker you can specify the registry used to create the image names by setting the `REGISTRY` environment variable (default value is `ghcr.io`).
> **Note**: You can build all local images at once by running `make docker-build-all`.
#### Building kyvernopre image locally
To build `kyvernopre` image on your local system, run:
```console
make docker-build-kyvernopre
```
The resulting image should be available locally, named `ghcr.io/kyverno/kyvernopre` (by default, if `REGISTRY` environment variable was not set).
#### Building kyverno image locally
To build `kyverno` image on your local system, run:
```console
make docker-build-kyverno
```
The resulting image should be available locally, named `ghcr.io/kyverno/kyverno` (by default, if `REGISTRY` environment variable was not set).
#### Building cli image locally
To build `cli` image on your local system, run:
```console
make docker-build-cli
```
The resulting image should be available locally, named `ghcr.io/kyverno/kyverno-cli` (by default, if `REGISTRY` environment variable was not set).
### Building local images with ko
When building local images with ko you can't specify the registry used to create the image names. It will always be `ko.local`.
> **Note**: You can build all local images at once by running `make ko-build-all`.
#### Building kyvernopre image locally
To build `kyvernopre` image on your local system, run:
```console
make ko-build-kyvernopre
```
The resulting image should be available locally, named `ko.local/github.com/kyverno/kyverno/cmd/initcontainer`.
#### Building kyverno image locally
To build `kyverno` image on your local system, run:
```console
make ko-build-kyverno
```
The resulting image should be available locally, named `ko.local/github.com/kyverno/kyverno/cmd/kyverno`.
#### Building cli image locally
To build `cli` image on your local system, run:
```console
make ko-build-cli
```
The resulting image should be available locally, named `ko.local/github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno`.
Pushing images is very similar to [building local images](#building-local-images), except that built images will be published on a remote image registry.
Currently, we are supporting two build systems:
- [Pushing images with docker](#pushing-images-with-docker)
- [Pushing images with ko](#pushing-images-with-ko)
> **Note**: We started with `docker` and are progressively moving to `ko`.
As the `ko` based build system matures, we will deprecate and remove `docker` based builds.
When pushing images you can specify the registry you want to publish images to by setting the `REGISTRY` environment variable (default value is `ghcr.io`).
<!-- TODO: explain the way images are tagged. -->
### Pushing images with docker
Authenticating to the remote registry is not done automatically in the `Makefile`.
You need to be authenticated before invoking targets responsible for pushing images.
> **Note**: You can push all images at once by running `make docker-publish-all` or `make docker-publish-all-dev`.
#### Pushing kyvernopre image
To push `kyvernopre` image on a remote registry, run:
```console
# push stable image
make docker-publish-kyvernopre
```
or
```console
# push dev image
make docker-publish-kyvernopre-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyvernopre` (by default, if `REGISTRY` environment variable was not set).
#### Pushing kyverno image
To push `kyverno` image on a remote registry, run:
```console
# push stable image
make docker-publish-kyverno
```
or
```console
# push dev image
make docker-publish-kyverno-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyverno` (by default, if `REGISTRY` environment variable was not set).
#### Pushing cli image
To push `cli` image on a remote registry, run:
```console
# push stable image
make docker-publish-cli
```
or
```console
# push dev image
make docker-publish-cli-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyverno-cli` (by default, if `REGISTRY` environment variable was not set).
### Pushing images with ko
Authenticating to the remote registry is done automatically in the `Makefile` with `ko login`.
To allow authentication you will need to set `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables before invoking targets responsible for pushing images.
> **Note**: You can push all images at once by running `make ko-publish-all` or `make ko-publish-all-dev`.
#### Pushing kyvernopre image
To push `kyvernopre` image on a remote registry, run:
```console
# push stable image
make ko-publish-kyvernopre
```
or
```console
# push dev image
make ko-publish-kyvernopre-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyvernopre` (by default, if `REGISTRY` environment variable was not set).
#### Pushing kyverno image
To push `kyverno` image on a remote registry, run:
```console
# push stable image
make ko-publish-kyverno
```
or
```console
# push dev image
make ko-publish-kyverno-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyverno` (by default, if `REGISTRY` environment variable was not set).
#### Pushing cli image
To push `cli` image on a remote registry, run:
```console
# push stable image
make ko-publish-cli
```
or
```console
# push dev image
make ko-publish-cli-dev
```
The resulting image should be available remotely, named `ghcr.io/kyverno/kyverno-cli` (by default, if `REGISTRY` environment variable was not set).
To build local images, load them on a local KinD cluster, and deploy helm charts, run:
```console
# build images, load them in KinD cluster and deploy kyverno helm chart
make kind-deploy-kyverno
```
or
```console
# deploy kyverno-policies helm chart
make kind-deploy-kyverno-policies
```
or
```console
# build images, load them in KinD cluster and deploy helm charts
make kind-deploy-all
```
This will build local images, load built images in every node of the KinD cluster, and deploy `kyverno` and/or `kyverno-policies` helm charts in the cluster (overriding image repositories and tags).
You can override the KinD cluster name by setting the `KIND_NAME` environment variable (default value is `kind`).