Build the controller manager container image¶
This document explains how to build the controller manager container image.
-
Install the following tools:
-
Clone the Git repository and navigate to the directory
projects/k8s-hybrid-neg-controller
.
The base image is defined by the fromImage
field in the Skaffold configuration
file in the project base directory: ../skaffold.yaml
.
Local container image storage¶
Build the container image and load it into your local Docker daemon or Podman container storage:
The default destination is /var/run/docker.sock
, but you can override the
destination using the DOCKER_HOST
environment variable.
Remote container image repository¶
Build the container image and push it to your container image repository:
You can specify the container image repository using either the default-repo
flag, or the SKAFFOLD_DEFAULT_REPO
environment variable.
See below for instructions specific to cloud provider container image registries.
Google Cloud's Artifact Registry¶
Build the container image and push it to a container image repository in Artifact Registry:
skaffold build --cache-artifacts=false --push --default-repo $AR_LOCATION-docker.pkg.dev/$PROJECT_ID/$AR_REPOSITORY
In the command above, replace the following:
$AR_LOCATION
: the location of your Artifact Registry repository.$PROJECT_ID
: the project ID of your Google Cloud project.$AR_REPOSITORY
: the name of your Artifact Registry repository name.
Amazon Elastic Container Registry¶
Build the container image and push it to an Amazon ECR repository:
AWS_ACCOUNT_ID=[your AWS account ID]
ECR_REGION=[the region of your ECR private repository, e.g., us-east-1]
ECR_REGISTRY=$AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com
ECR_REPOSITORY_NAME=hybrid-neg-controller-manager
aws ecr create-repository --region $ECR_REGION --repository-name $ECR_REPOSITORY_NAME
skaffold build --cache-artifacts=false --push --default-repo $ECR_REGISTRY
Azure Container Registry¶
Build the container image and push it to a private registry in Azure Container Registry:
ACR_NAME=<the name if your private registry in Azure Container Registry>
ACR_RESOURCE_GROUP=<the Azure resource group that contains your registry>
ACR_LOGIN_SERVER=$(az acr show \
--name $ACR_NAME \
--expose-token \
--resource-group $ACR_RESOURCE_GROUP \
--output tsv \
--query loginServer)
skaffold build --cache-artifacts=false --push --default-repo $ACR_LOGIN_SERVER
Building with ko
¶
You can use the ko
command-line tool to build the
container image, instead of
Skaffold's ko
builder.
-
Download the
ko
binary for your platform. -
Define the base image you want to use in the
.ko.yaml
config file:You can specify the base image using the
KO_DEFAULTBASEIMAGE
environment variable, instead of creating the.ko.yaml
config file.For additional configuration options, see the documentation on
ko
configuration. -
Specify the container image repository where
ko
should push the container image using theKO_DOCKER_REPO
environment variable: -
Build the container image and push it to the repository: