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

(server) Serve CatalogMetadata resource with aggregated server #107

Closed
Closed
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
16 changes: 16 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ builds:
- arm64
- ppc64le
- s390x
- id: server
main: ./cmd/server/
binary: server
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}"
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}"
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}"
tags:
- "{{ .Env.GO_BUILD_TAGS }}"
mod_timestamp: "{{ .CommitTimestamp }}"
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
dockers:
- image_templates:
- "{{ .Env.IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY manager .
COPY server .
USER 65532:65532

ENTRYPOINT ["/manager"]
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ clean: ## Remove binaries and test artifacts
generate: $(CONTROLLER_GEN) ## Generate code and manifests.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
rm config/crd/bases/optional.catalogd.operatorframework.io_catalogmetadata.yaml

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down Expand Up @@ -83,7 +84,7 @@ lint: $(GOLANGCI_LINT) ## Run golangci linter.

##@ Build

BINARIES=manager
BINARIES=manager server
LINUX_BINARIES=$(join $(addprefix linux/,$(BINARIES)), )

# Build info
Expand Down Expand Up @@ -152,25 +153,33 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)

.PHONY: install
install: build-container kind-load deploy wait ## Install local catalogd
install: cert-manager build-container kind-load deploy wait ## Install local catalogd

.PHONY: deploy
deploy: $(KUSTOMIZE) ## Deploy Catalogd to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE)
cd config/server && $(KUSTOMIZE) edit set image server=$(IMAGE)
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy
undeploy: $(KUSTOMIZE) ## Undeploy Catalogd from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=true -f -

.PHONY: cert-manager
cert-manager: ## Deploy cert-manager on the cluster
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MGR_VERSION)/cert-manager.yaml
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager --timeout=60s
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-cainjector --timeout=60s
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s
Comment on lines +171 to +173
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the weird spacing here just a GH thing or are these intentionally tabbed over?


wait:
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-controller-manager --timeout=60s
kubectl wait --for=condition=Available --namespace=$(CATALOGD_NAMESPACE) deployment/catalogd-server --timeout=60s

##@ Release

export ENABLE_RELEASE_PIPELINE ?= false
export GORELEASER_ARGS ?= --snapshot --clean
export CERT_MGR_VERSION ?= $(CERT_MGR_VERSION)
release: $(GORELEASER) ## Runs goreleaser for catalogd. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
$(GORELEASER) $(GORELEASER_ARGS)

Expand Down
79 changes: 0 additions & 79 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions api/optional/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package,register
// +groupName=optional.catalogd.operatorframework.io

// Package api is the internal version of the API.
package optional
41 changes: 41 additions & 0 deletions api/optional/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the optional v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=optional.catalogd.operatorframework.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "optional.catalogd.operatorframework.io", Version: "v1alpha1"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: The Group name containing optional seems like it could be confusing. In reality these apis aren't "optional" in the sense that you can just choose to not use them right? Maybe something like storage.catalogd.operatorframework.io would be better?


// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource takes an unqualified resource and returns back a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return GroupVersion.WithResource(resource).GroupResource()
}
106 changes: 106 additions & 0 deletions api/optional/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (

//+kubebuilder:scaffold:imports
"github.com/operator-framework/catalogd/api/core/v1alpha1"
optionalv1alpha1 "github.com/operator-framework/catalogd/api/optional/v1alpha1"
)

var (
Expand All @@ -53,6 +54,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(optionalv1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
20 changes: 20 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"flag"

genericapiserver "k8s.io/apiserver/pkg/server"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/operator-framework/catalogd/pkg/catalogserver"
)

func main() {
stopCh := genericapiserver.SetupSignalHandler()
options := catalogserver.NewServerOptions()
cmd := catalogserver.NewCommandStartServer(options, stopCh)
cmd.Flags().AddGoFlagSet(flag.CommandLine)
if err := cmd.Execute(); err != nil {
log.Log.Error(err, "unable to start server ")
}
}
1 change: 0 additions & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ resources:
- bases/catalogd.operatorframework.io_bundlemetadata.yaml
- bases/catalogd.operatorframework.io_packages.yaml
- bases/catalogd.operatorframework.io_catalogs.yaml
- bases/catalogd.operatorframework.io_catalogmetadata.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
Expand Down
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ resources:
- ../crd
- ../rbac
- ../manager
- ../server
patches:
- path: manager_auth_proxy_patch.yaml
Loading
Loading