Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes to push docker image #688

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ dockers:

# Templates of the Docker image names.
image_templates:
- "pulumi/{{ .ProjectName }}:latest"
- "pulumi/{{ .ProjectName }}:{{ .Tag }}"

build_flag_templates:
Expand Down
2 changes: 1 addition & 1 deletion operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ARG VERSION
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager -ldflags="-X github.com/pulumi/pulumi-kubernetes-operator/operator/version.Version=${VERSION}" cmd/main.go

# Build the agent binary
FROM golang:1.22 AS agent-builder
FROM --platform=${BUILDPLATFORM} golang:1.22 AS agent-builder
EronWright marked this conversation as resolved.
Show resolved Hide resolved
ARG TARGETOS
ARG TARGETARCH

Expand Down
22 changes: 10 additions & 12 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.1
VERSION ?= v2.0-devel

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand All @@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# pulumi.com/pulumi-kubernetes-operator-v2-bundle:$VERSION and pulumi.com/pulumi-kubernetes-operator-v2-catalog:$VERSION.
IMAGE_TAG_BASE ?= pulumi.com/pulumi-kubernetes-operator-v2
# pulumi.com/pulumi-kubernetes-operator-bundle:$VERSION and pulumi.com/pulumi-kubernetes-operator-catalog:$VERSION.
IMAGE_TAG_BASE ?= pulumi.com/pulumi-kubernetes-operator

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand All @@ -51,7 +51,7 @@ endif
OPERATOR_SDK_VERSION ?= v1.35.0

# Image URL to use all building/pushing image targets
IMG ?= pulumi/pulumi-kubernetes-operator-v2
IMG ?= pulumi/pulumi-kubernetes-operator
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.3

Expand Down Expand Up @@ -96,8 +96,9 @@ help: ## Display this help.
##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
manifests: controller-gen kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:crdVersions=v1,generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}:${VERSION}

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down Expand Up @@ -162,21 +163,18 @@ docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}:${VERSION}

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# architectures. To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# - be able to push the image to your registry (to IMG:VERSION)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
PLATFORMS ?= linux/arm64,linux/amd64
.PHONY: docker-buildx
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --build-context agent=../agent --tag ${IMG}:${VERSION} -f Dockerfile .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

##@ Deployment

Expand Down
4 changes: 2 additions & 2 deletions operator/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: pulumi/pulumi-kubernetes-operator-v2
newTag: latest
newName: pulumi/pulumi-kubernetes-operator
newTag: v2.0-devel
resources:
- manager.yaml
2 changes: 1 addition & 1 deletion operator/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestE2E(t *testing.T) {
b := make([]byte, 12)
_, _ = rand.Read(b) //nolint:staticcheck // Don't need crypto here.
tag := hex.EncodeToString(b)
projectimage := "pulumi/pulumi-kubernetes-operator-v2:" + tag
projectimage := "pulumi/pulumi-kubernetes-operator:" + tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry about folks currently using pulumi/pulumi-kubernetes-operator:latest. This has the potential to break people, or at least require some manual migration steps -- assuming we eventually publish v2 to latest.

Copy link
Contributor Author

@EronWright EronWright Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sympathize. My plan is to NOT apply a suffix, but also NOT push to latest. Then, in coming weeks, we will see whether usage of latest tapers off.


cmd := exec.Command("make", "docker-build", "VERSION="+tag)
require.NoError(t, run(cmd), "failed to build image")
Expand Down
2 changes: 1 addition & 1 deletion operator/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pulumi/pulumi-kubernetes-operator/operator

go 1.23.1
go 1.23

require (
github.com/fluxcd/source-controller/api v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions operator/internal/controller/auto/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ func labelsForStatefulSet(w *autov1alpha1.Workspace) map[string]string {
}

func newStatefulSet(ctx context.Context, w *autov1alpha1.Workspace, source *sourceSpec) (*appsv1.StatefulSet, error) {
// TODO: get from configuration
workspaceAgentImage := "pulumi/pulumi-kubernetes-operator-v2:" + version.Version
// TODO: get from environment
workspaceAgentImage := "pulumi/pulumi-kubernetes-operator:" + version.Version

labels := labelsForStatefulSet(w)

Expand Down