Skip to content
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
30 changes: 0 additions & 30 deletions .github/workflows/go.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ WORKDIR /hypershift

COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/hypershift-operator hypershift-operator/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/control-plane-operator control-plane-operator/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/hosted-cluster-config-operator hosted-cluster-config-operator/main.go

FROM quay.io/openshift/origin-base:4.6
COPY --from=builder /hypershift/bin/hypershift-operator /usr/bin/hypershift-operator
COPY --from=builder /hypershift/bin/control-plane-operator /usr/bin/control-plane-operator
COPY --from=builder /hypershift/bin/hosted-cluster-config-operator /usr/bin/hosted-cluster-config-operator
59 changes: 36 additions & 23 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
# Hacking

### Development workflow
## Development How-to Guides

Often it's easiest to develop the operator locally connected to a remote
cluster.

In this case, you might want to install with the development Kustomize
profile which uses 0 replicas for the operator deployment by default. This
makes it easy to iterate on the non-deployment manifests in conjunction
with the operator binary itself.
### Run the operator in a local process

Starting from clean management cluster, run the following to get started:
1. Ensure KUBECONFIG points to a management cluster with no HyperShift installed yet.

```bash
$ make build
2. Build HyperShift.

$ make install PROFILE=development
make build

$ make run-local
```
3. Install HyperShift with the operator deployment scaled to zero so that it
doesn't conflict with your local operator process.

Or you might want to run your own image in the cluster to do integration
testing, in which case you may want to use the default (production) profile
and use `kubectl set image` (for example) to update the deployment.
make install PROFILE=development

### Testing
4. Run the HyperShift operator locally.

To run the e2e tests, install HyperShift (using whatever profile you want) and
then run:
make run-local

```bash
$ make test-e2e
```
### Run custom operator images

1. Build and push a custom image build to your own repository.

make IMG=quay.io/my/hypershift:latest docker-build docker-push

2. Deploy the latest production version.

make install PROFILE=production

3. Reconfigure the HyperShift operator deployment to use your custom image.
This will also cause the image you specify to be used for the hosted cluster
config operator as well.

oc --namespace hypershift set image deployment/operator operator=quay.io/my/hypershift:latest

### Run the e2e tests

1. Install HyperShift.

make install PROFILE=production

2. Run the tests.

make test-e2e

### Visualizing dependencies
### Visualize the Go dependency tree

MacOS
```
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ endif

all: build manifests

build: hypershift-operator control-plane-operator
build: hypershift-operator hosted-cluster-config-operator

verify: build fmt vet

Expand All @@ -46,9 +46,9 @@ generate:
hypershift-operator: generate
$(GO_BUILD_RECIPE) -o bin/hypershift-operator ./hypershift-operator

# Build control-plane-operator binary
control-plane-operator: generate
$(GO_BUILD_RECIPE) -o bin/control-plane-operator ./control-plane-operator
# Build hosted-cluster-config-operator binary
hosted-cluster-config-operator: generate
$(GO_BUILD_RECIPE) -o bin/hosted-cluster-config-operator ./hosted-cluster-config-operator

# Run tests
test: build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
informerFactory := informers.NewSharedInformerFactory(cfg.TargetKubeClient(), controllers.DefaultResync)
cfg.Manager().Add(manager.RunnableFunc(func(ctx context.Context) error {
informerFactory.Start(ctx.Done())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
clusterOperators := cfg.TargetConfigInformers().Config().V1().ClusterOperators()
reconciler := &ControlPlaneClusterOperatorSyncer{
Versions: cfg.Versions(),
Client: cfg.TargetConfigClient(),
Lister: clusterOperators.Lister(),
Log: cfg.Logger().WithName("ControlPlaneClusterOperatorSyncer"),
Log: cfg.Logger().WithName("HostedClusterConfigOperatorSyncer"),
}
c, err := controller.New("control-plane-operator-syncer", cfg.Manager(), controller.Options{Reconciler: reconciler})
c, err := controller.New("hosted-cluster-config-operator-syncer", cfg.Manager(), controller.Options{Reconciler: reconciler})
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
configclient "github.com/openshift/client-go/config/clientset/versioned"
configinformers "github.com/openshift/client-go/config/informers/externalversions"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
openshiftClient, err := configclient.NewForConfig(cfg.TargetConfig())
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

const (
Expand All @@ -16,14 +16,14 @@ const (
syncInterval = 10 * time.Minute
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
if err := setupConfigMapObserver(cfg); err != nil {
return err
}
return nil
}

func setupConfigMapObserver(cfg *operator.ControlPlaneOperatorConfig) error {
func setupConfigMapObserver(cfg *operator.HostedClusterConfigOperatorConfig) error {
informerFactory := cfg.TargetKubeInformersForNamespace(ManagedConfigNamespace)
configMaps := informerFactory.Core().V1().ConfigMaps()
reconciler := &ManagedCAObserver{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

configv1 "github.com/openshift/api/config/v1"

"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

const (
Expand All @@ -31,7 +31,7 @@ func init() {
}
}

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
infrastructures := cfg.TargetConfigInformers().Config().V1().Infrastructures()
sourceInfraConfigMap, err := cfg.KubeClient().CoreV1().ConfigMaps(cfg.Namespace()).Get(context.TODO(), infrastructureConfigMap, metav1.GetOptions{})
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

const (
KubeAdminSecret = "kubeadmin"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
informerFactory := informers.NewSharedInformerFactoryWithOptions(cfg.TargetKubeClient(), controllers.DefaultResync, informers.WithNamespace(metav1.NamespaceSystem))
cfg.Manager().Add(manager.RunnableFunc(func(ctx context.Context) error {
informerFactory.Start(ctx.Done())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

const (
ManagedConfigNamespace = "openshift-config-managed"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {

informerFactory := cfg.TargetKubeInformersForNamespace(ManagedConfigNamespace)
configMaps := informerFactory.Core().V1().ConfigMaps()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
// syncInterval is the amount of time to use between checks
var syncInterval = 20 * time.Minute

// controlPlaneOperatorConfig is the name of the source configmap on the management cluster
const controlPlaneOperatorConfig = "control-plane-operator"
// hostedClusterConfigOperatorConfig is the name of the source configmap on the management cluster
const hostedClusterConfigOperatorConfig = "hosted-cluster-config-operator"

type KubeletServingCASyncer struct {
TargetClient kubeclient.Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
informerFactory := informers.NewSharedInformerFactory(cfg.TargetKubeClient(), controllers.DefaultResync)
cfg.Manager().Add(manager.RunnableFunc(func(ctx context.Context) error {
informerFactory.Start(ctx.Done())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
targetCfg := cfg.TargetConfig()
kubeInformers := kubeinformers.NewSharedInformerFactoryWithOptions(cfg.TargetKubeClient(), controllers.DefaultResync, kubeinformers.WithNamespace("openshift-apiserver"))
configClient, err := configclient.NewForConfig(targetCfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/source"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
apiextClient, err := apiextensionsclient.NewForConfig(cfg.TargetConfig())
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"github.com/openshift/library-go/pkg/operator/configobserver"
"github.com/openshift/library-go/pkg/operator/events"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
targetCfg := cfg.TargetConfig()
kubeInformers := kubeinformers.NewSharedInformerFactoryWithOptions(cfg.TargetKubeClient(), controllers.DefaultResync, kubeinformers.WithNamespace("openshift-controller-manager-operator"))
configClient, err := configclient.NewForConfig(targetCfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
routeclient "github.com/openshift/client-go/route/clientset/versioned"
routeinformers "github.com/openshift/client-go/route/informers/externalversions"

"openshift.io/hypershift/control-plane-operator/controllers"
"openshift.io/hypershift/control-plane-operator/operator"
"openshift.io/hypershift/hosted-cluster-config-operator/controllers"
"openshift.io/hypershift/hosted-cluster-config-operator/operator"
)

func Setup(cfg *operator.ControlPlaneOperatorConfig) error {
func Setup(cfg *operator.HostedClusterConfigOperatorConfig) error {
targetClient, err := routeclient.NewForConfig(cfg.TargetConfig())
if err != nil {
return err
Expand Down
Loading