Skip to content

Commit

Permalink
Add galaxy default EE
Browse files Browse the repository at this point in the history
closes pulp#821
  • Loading branch information
git-hyagi committed Dec 8, 2022
1 parent dc1687d commit c0a1b61
Show file tree
Hide file tree
Showing 14 changed files with 384 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .ci/scripts/local.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

kustomize build config/local | kubectl apply -f -
kustomize build config/local | kubectl apply --server-side=true -f -
make manifests generate fmt vet CR_KIND=$1 CR_DOMAIN=$2 CR_PLURAL=$3 APP_IMAGE=$4 WEB_IMAGE=$5
if [[ "$CI_TEST" == "true" ]] ; then
make build
Expand Down
1 change: 1 addition & 0 deletions CHANGES/821.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a feature to deploy and sync Galaxy execution environments.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -
$(KUSTOMIZE) build config/crd | kubectl apply --server-side=true -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand All @@ -224,7 +224,7 @@ local: kustomize ## Run controller in the K8s cluster specified in ~/.kube/confi
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit set namespace ${NAMESPACE}
$(KUSTOMIZE) build config/default | kubectl apply -f -
$(KUSTOMIZE) build config/default | kubectl apply --server-side=true -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/repo_manager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ type PulpSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
Cache Cache `json:"cache,omitempty"`

// Galaxy defines the resources that are specific to Galaxy deployments
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
Galaxy Galaxy `json:"galaxy,omitempty"`

// Definition of /etc/pulp/settings.py config file.
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -732,6 +737,21 @@ type Cache struct {
Strategy appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// Galaxy defines the resources that are specific to Galaxy deployments
type Galaxy struct {
// Define if the operator should or should not deploy the default Execution Environments.
// Default: false
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
DeployEEDefaults bool `json:"deploy_ee_defaults,omitempty"`

// Name of the ConfigMap with the list of Execution Environments that should be synchronized.
// Default: ee-default-images
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
EEDefaults string `json:"ee_defaults,omitempty"`
}

// PulpStatus defines the observed state of Pulp
type PulpStatus struct {
//+operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"}
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

13 changes: 13 additions & 0 deletions config/crd/bases/repo-manager.pulpproject.org_pulps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5800,6 +5800,19 @@ spec:
file_storage_storage_class:
description: Storage class to use for the file persistentVolumeClaim
type: string
galaxy:
description: Galaxy defines the resources that are specific to Galaxy
deployments
properties:
deploy_ee_defaults:
description: 'Define if the operator should or should not deploy
the default Execution Environments. Default: false'
type: boolean
ee_defaults:
description: 'Name of the ConfigMap with the list of Execution
Environments that should be synchronized. Default: ee-default-images'
type: string
type: object
haproxy_timeout:
description: 'The timeout for HAProxy. Default: "180s"'
type: string
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down
13 changes: 13 additions & 0 deletions controllers/repo_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [Cache](#cache)
* [Content](#content)
* [Database](#database)
* [Galaxy](#galaxy)
* [PulpList](#pulplist)
* [PulpSpec](#pulpspec)
* [PulpStatus](#pulpstatus)
Expand Down Expand Up @@ -106,6 +107,17 @@ Database defines desired state of postgres

[Back to Custom Resources](#custom-resources)

#### Galaxy

Galaxy defines the resources that are specific to Galaxy deployments

| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| deploy_ee_defaults | Define if the operator should or should not deploy the default Execution Environments. Default: false | bool | false |
| ee_defaults | Name of the ConfigMap with the list of Execution Environments that should be synchronized. Default: ee-default-images | string | false |

[Back to Custom Resources](#custom-resources)

#### Pulp

Pulp is the Schema for the pulps API
Expand Down Expand Up @@ -175,6 +187,7 @@ PulpSpec defines the desired state of Pulp
| worker | Worker defines desired state of pulpcore-worker resources | [Worker](#worker) | false |
| web | Web defines desired state of pulpcore-web (reverse-proxy) resources | [Web](#web) | false |
| cache | Cache defines desired state of redis resources | [Cache](#cache) | false |
| galaxy | Galaxy defines the resources that are specific to Galaxy deployments | [Galaxy](#galaxy) | false |
| pulp_settings | Definition of /etc/pulp/settings.py config file. | runtime.RawExtension | false |
| image_web | The image name (repo name) for the pulp webserver image. Default: \"quay.io/pulp/pulp-web\" | string | false |
| image_web_version | The image version for the pulp webserver image. Default: \"stable\" | string | false |
Expand Down
16 changes: 1 addition & 15 deletions controllers/repo_manager/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"os"
"strconv"
"strings"
"time"

"golang.org/x/text/cases"
Expand All @@ -35,7 +34,6 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/go-logr/logr"
configv1 "github.com/openshift/api/config/v1"
repomanagerv1alpha1 "github.com/pulp/pulp-operator/api/v1alpha1"
"github.com/pulp/pulp-operator/controllers"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -789,19 +787,7 @@ func pulpServerSecret(resources FunctionResources) client.Object {
}

// Handling user facing URLs
rootUrl := "http://" + resources.Pulp.Name + "-web-svc." + resources.Pulp.Namespace + ".svc.cluster.local:24880"
if strings.ToLower(resources.Pulp.Spec.IngressType) == "ingress" {
rootUrl = "https://" + resources.Pulp.Spec.IngressHost
}
if strings.ToLower(resources.Pulp.Spec.IngressType) == "route" {
if len(resources.Pulp.Spec.RouteHost) == 0 {
ingress := &configv1.Ingress{}
resources.RepoManagerReconciler.Get(resources.Context, types.NamespacedName{Name: "cluster"}, ingress)
rootUrl = "https://" + resources.Pulp.Name + "." + ingress.Spec.Domain
} else {
rootUrl = "https://" + resources.Pulp.Spec.RouteHost
}
}
rootUrl := getRootURL(resources)

// default settings.py configuration
var pulp_settings = `DB_ENCRYPTION_KEY = "/etc/pulp/keys/database_fields.symmetric.key"
Expand Down
7 changes: 7 additions & 0 deletions controllers/repo_manager/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"golang.org/x/text/cases"
"golang.org/x/text/language"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
policy "k8s.io/api/policy/v1"
Expand Down Expand Up @@ -70,6 +71,7 @@ type RepoManagerReconciler struct {
//+kubebuilder:rbac:groups=core,namespace=pulp-operator-system,resources=configmaps;secrets;services;persistentvolumeclaims,verbs=create;update;patch;delete;watch;get;list;
//+kubebuilder:rbac:groups="",namespace=pulp-operator-system,resources=events,verbs=create;patch
//+kubebuilder:rbac:groups=policy,namespace=pulp-operator-system,resources=poddisruptionbudgets,verbs=get;list;create;delete;patch;update;watch
//+kubebuilder:rbac:groups=batch,namespace=pulp-operator-system,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down Expand Up @@ -305,6 +307,10 @@ func (r *RepoManagerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return pulpController, err
}

if pulpController, err := galaxy(FunctionResources{ctx, pulp, log, r}); needsRequeue(err, pulpController) {
return pulpController, err
}

log.V(1).Info("Running status tasks")
pulpController, err = r.pulpStatus(ctx, pulp, log)
if needsRequeue(err, pulpController) {
Expand Down Expand Up @@ -332,6 +338,7 @@ func (r *RepoManagerReconciler) SetupWithManager(mgr ctrl.Manager) error {
Owns(&corev1.ConfigMap{}).
Owns(&policy.PodDisruptionBudget{}).
Owns(&corev1.ServiceAccount{}).
Owns(&batchv1.CronJob{}, builder.WithPredicates(ignoreCronjobStatus())).
Owns(&netv1.Ingress{})

if IsOpenShift, _ := controllers.IsOpenShift(); IsOpenShift {
Expand Down
Loading

0 comments on commit c0a1b61

Please sign in to comment.