Skip to content

Commit

Permalink
Merge pull request #1887 from barney-s/remove-image-registry-param
Browse files Browse the repository at this point in the history
[cleanup] Remove image-registry parameter from the composition controller
  • Loading branch information
google-oss-prow[bot] authored May 24, 2024
2 parents f8e2a25 + 6abb8da commit eb1cc36
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 44 deletions.
6 changes: 1 addition & 5 deletions experiments/compositions/composition/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ build: manifests generate fmt vet ## Build manager binary.

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go --image-registry gcr.io/$(GCP_PROJECT_ID)
go run ./cmd/main.go

.PHONY: debug
debug: generate fmt vet manifests
Expand Down Expand Up @@ -150,24 +150,20 @@ release-manifests: manifests kustomize
.PHONY: release-test-cc-manifests
release-test-cc-manifests: common-test-manifests
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit add patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/args/-\", \"value\": \"--image-registry=gcr.io/$(GCP_PROJECT_ID)\"}]"
cd config/default && $(KUSTOMIZE) edit add patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/imagePullPolicy\", \"value\": \"Always\"}]"
cd config/expanders && $(KUSTOMIZE) edit set image expander-jinja2=${JINJA_IMG}
$(KUSTOMIZE) build config/default -o release/test/cc-operator.yaml
cd config/manager && $(KUSTOMIZE) edit set image controller=composition:latest
cd config/default && $(KUSTOMIZE) edit remove patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/args/-\", \"value\": \"--image-registry=gcr.io/$(GCP_PROJECT_ID)\"}]"
cd config/default && $(KUSTOMIZE) edit remove patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/imagePullPolicy\", \"value\": \"Always\"}]"
cd config/expanders && $(KUSTOMIZE) edit set image expander-jinja2=expander-jinja2:latest

.PHONY: release-kind-manifests
release-test-kind-manifests: common-test-manifests
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/expanders && $(KUSTOMIZE) edit set image expander-jinja2=${JINJA_IMG}
cd config/default && $(KUSTOMIZE) edit add patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/args/-\", \"value\": \"--image-registry=gcr.io/$(GCP_PROJECT_ID)\"}]"
$(KUSTOMIZE) build config/default -o release/test/kind-operator.yaml
cd config/manager && $(KUSTOMIZE) edit set image controller=composition:latest
cd config/expanders && $(KUSTOMIZE) edit set image expander-jinja2=expander-jinja2:latest
cd config/default && $(KUSTOMIZE) edit remove patch --namespace system --name controller-manager --kind Deployment --patch "[{\"op\": \"add\", \"path\": \"/spec/template/spec/containers/1/args/-\", \"value\": \"--image-registry=gcr.io/$(GCP_PROJECT_ID)\"}]"

.PHONY: deploy-kind
deploy-kind: release-test-kind-manifests docker-build docker-build-inline docker-build-expander-jinja2
Expand Down
9 changes: 3 additions & 6 deletions experiments/compositions/composition/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var imageRegistry string
flag.StringVar(&imageRegistry, "image-registry", "gcr.io/krmapihosting-release", "docker image registry.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
Expand Down Expand Up @@ -98,10 +96,9 @@ func main() {
}

if err = (&controller.CompositionReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
ImageRegistry: imageRegistry,
Recorder: mgr.GetEventRecorderFor("composition"),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("composition"),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Composition")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ resources:

patches:
- path: manager_auth_proxy_patch.yaml
- patch: '[{"op": "add", "path": "/spec/template/spec/containers/1/args/-", "value":
"--image-registry=gcr.io/krmapihosting-release"}]'
target:
kind: Deployment
name: controller-manager
namespace: system
- patch: '[{"op": "add", "path": "/spec/template/spec/containers/1/imagePullPolicy",
"value": "Always"}]'
target:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ var FacadeControllers sync.Map
// CompositionReconciler reconciles a Composition object
type CompositionReconciler struct {
client.Client
Scheme *runtime.Scheme
Recorder record.EventRecorder
mgr ctrl.Manager
ImageRegistry string
Scheme *runtime.Scheme
Recorder record.EventRecorder
mgr ctrl.Manager
}

//+kubebuilder:rbac:groups=composition.google.com,resources=compositions,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -169,15 +168,14 @@ func (r *CompositionReconciler) processComposition(

logger.Info("Starting Reconciler for InputAPI CRD")
expanderController := &ExpanderReconciler{
Client: r.Client,
Recorder: r.mgr.GetEventRecorderFor(crd.Spec.Names.Plural + "-expander"),
Scheme: r.Scheme,
InputGVK: gvk,
ImageRegistry: r.ImageRegistry,
Composition: types.NamespacedName{Name: c.Name, Namespace: c.Namespace},
InputGVR: gvk.GroupVersion().WithResource(crd.Spec.Names.Plural),
RESTMapper: r.mgr.GetRESTMapper(),
Config: r.mgr.GetConfig(),
Client: r.Client,
Recorder: r.mgr.GetEventRecorderFor(crd.Spec.Names.Plural + "-expander"),
Scheme: r.Scheme,
InputGVK: gvk,
Composition: types.NamespacedName{Name: c.Name, Namespace: c.Namespace},
InputGVR: gvk.GroupVersion().WithResource(crd.Spec.Names.Plural),
RESTMapper: r.mgr.GetRESTMapper(),
Config: r.mgr.GetConfig(),
}

if err := expanderController.SetupWithManager(r.mgr, cr); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ import (
// ExpanderReconciler reconciles a expander object
type ExpanderReconciler struct {
client.Client
Scheme *runtime.Scheme
Recorder record.EventRecorder
RESTMapper meta.RESTMapper
Config *rest.Config
ImageRegistry string
Dynamic *dynamic.DynamicClient
InputGVK schema.GroupVersionKind
InputGVR schema.GroupVersionResource
Composition types.NamespacedName
Scheme *runtime.Scheme
Recorder record.EventRecorder
RESTMapper meta.RESTMapper
Config *rest.Config
Dynamic *dynamic.DynamicClient
InputGVK schema.GroupVersionKind
InputGVR schema.GroupVersionResource
Composition types.NamespacedName
}

var planGVK schema.GroupVersionKind = schema.GroupVersionKind{
Expand Down
1 change: 0 additions & 1 deletion experiments/compositions/composition/release/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,6 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --image-registry=gcr.io/krmapihosting-release
command:
- /manager
image: gcr.io/krmapihosting-release/composition:v0.0.1.alpha
Expand Down
7 changes: 3 additions & 4 deletions experiments/compositions/composition/tests/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
utilruntime.Must(compositionv1alpha1.AddToScheme(scheme))
}

func StartLocalController(config *rest.Config, imageRegistry string) error {
func StartLocalController(config *rest.Config) error {
mgr, err := ctrl.NewManager(config, ctrl.Options{
Scheme: scheme,
LeaderElection: false,
Expand All @@ -50,9 +50,8 @@ func StartLocalController(config *rest.Config, imageRegistry string) error {
}

if err = (&controller.CompositionReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
ImageRegistry: imageRegistry,
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
return fmt.Errorf("unable to create Composition controller: %w", err)
}
Expand Down

0 comments on commit eb1cc36

Please sign in to comment.