Skip to content

Commit

Permalink
Merge branch 'main' into go-mod-consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
pdettori authored Mar 6, 2024
2 parents 7acd43c + 4a038a9 commit a7d96b7
Show file tree
Hide file tree
Showing 25 changed files with 499 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
EMAIL: ${{ github.actor}}@users.noreply.github.com

- name: Set up Helm
uses: azure/setup-helm@v3
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/test-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: E2E test

on:
workflow_call:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*'

jobs:
test-controlplane-lifecycle-management:
name: Test ControlPlane lifecycle management
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version: v1.19
cache: true

- name: Install kubectl
uses: azure/setup-kubectl@v3
id: install

- name: Run test
run: |
test/e2e/run.sh
- name: Show kubeconfig contexts
if: always()
run: kubectl config get-contexts

- name: Show running components of KubeFlex
if: always()
run: kubectl --context kind-kubeflex -n kubeflex-system get all

- name: Show logs of the KubeFlex controller manager
if: always()
run: kubectl --context kind-kubeflex -n kubeflex-system logs deploy/kubeflex-controller-manager

- name: Show logs of the shared Postgres DB
if: always()
run: kubectl --context kind-kubeflex -n kubeflex-system logs sts/postgres-postgresql

- name: Show logs of the KubeFlex operator
if: always()
run: kubectl --context kind-kubeflex -n kubeflex-system logs job/kubeflex-operator
7 changes: 4 additions & 3 deletions api/v1alpha1/controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (

// ControlPlaneSpec defines the desired state of ControlPlane
type ControlPlaneSpec struct {
Type ControlPlaneType `json:"type,omitempty"`
Backend BackendDBType `json:"backend,omitempty"`
PostCreateHook *string `json:"postCreateHook,omitempty"`
Type ControlPlaneType `json:"type,omitempty"`
Backend BackendDBType `json:"backend,omitempty"`
PostCreateHook *string `json:"postCreateHook,omitempty"`
PostCreateHookVars map[string]string `json:"postCreateHookVars,omitempty"`
}

// ControlPlaneStatus defines the observed state of ControlPlane
Expand Down
7 changes: 7 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.

9 changes: 9 additions & 0 deletions chart/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
type: string
postCreateHook:
type: string
postCreateHookVars:
additionalProperties:
type: string
type: object
type:
enum:
- k8s
Expand Down Expand Up @@ -877,6 +881,11 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
env:
- name: HELM_CONFIG_HOME
value: /tmp
- name: HELM_CACHE_HOME
value: /tmp
image: ghcr.io/kubestellar/kubeflex/manager:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down
6 changes: 3 additions & 3 deletions chart/templates/postgresql-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ roleRef:
subjects:
- kind: ServiceAccount
name: helm-install-sa
namespace: kubeflex-system
namespace: {{ .Release.Namespace }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down Expand Up @@ -94,7 +94,7 @@ spec:
- --version
- 13.1.5
- --namespace
- kubeflex-system
- {{ .Release.Namespace }}
- --set
- primary.extendedConfiguration=max_connections=1000
- --set
Expand Down Expand Up @@ -165,7 +165,7 @@ spec:
- uninstall
- postgres
- --namespace
- kubeflex-system
- {{ .Release.Namespace }}
env:
- name: HELM_CONFIG_HOME
value: "/tmp"
Expand Down
21 changes: 18 additions & 3 deletions cmd/kflex/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"os"
"strings"
"sync"

tenancyv1alpha1 "github.com/kubestellar/kubeflex/api/v1alpha1"
Expand All @@ -38,7 +39,7 @@ type CPCreate struct {
}

// Create a ne control plane
func (c *CPCreate) Create(controlPlaneType, backendType, hook string, chattyStatus bool) {
func (c *CPCreate) Create(controlPlaneType, backendType, hook string, hookVars []string, chattyStatus bool) {
done := make(chan bool)
var wg sync.WaitGroup
cx := cont.CPCtx{}
Expand All @@ -51,7 +52,7 @@ func (c *CPCreate) Create(controlPlaneType, backendType, hook string, chattyStat
}
cl := *clp

cp := c.generateControlPlane(controlPlaneType, backendType, hook)
cp := c.generateControlPlane(controlPlaneType, backendType, hook, hookVars)

util.PrintStatus(fmt.Sprintf("Creating new control plane %s of type %s ...", c.Name, controlPlaneType), done, &wg, chattyStatus)
if err := cl.Create(context.TODO(), cp, &client.CreateOptions{}); err != nil {
Expand Down Expand Up @@ -104,7 +105,7 @@ func (c *CPCreate) Create(controlPlaneType, backendType, hook string, chattyStat
wg.Wait()
}

func (c *CPCreate) generateControlPlane(controlPlaneType, backendType, hook string) *tenancyv1alpha1.ControlPlane {
func (c *CPCreate) generateControlPlane(controlPlaneType, backendType, hook string, hookVars []string) *tenancyv1alpha1.ControlPlane {
cp := &tenancyv1alpha1.ControlPlane{
ObjectMeta: v1.ObjectMeta{
Name: c.Name,
Expand All @@ -116,6 +117,20 @@ func (c *CPCreate) generateControlPlane(controlPlaneType, backendType, hook stri
}
if hook != "" {
cp.Spec.PostCreateHook = &hook
cp.Spec.PostCreateHookVars = convertToMap(hookVars)
}
return cp
}

func convertToMap(pairs []string) map[string]string {
params := make(map[string]string)

for _, pair := range pairs {
split := strings.SplitN(pair, "=", 2)
if len(split) == 2 {
params[split[0]] = split[1]
}
}

return params
}
6 changes: 0 additions & 6 deletions cmd/kflex/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ func Init(ctx context.Context, kubeconfig, version, buildDate string, domain, ex
ensureKFlexOperator(ctx, version, domain, externalPort, isOCP)
done <- true

if isOCP {
util.PrintStatus("Adding OpenShift anyuid SCC to kubeflex SA...", done, &wg, chattyStatus)
util.AddSCCtoUserPolicy("")
done <- true
}

util.PrintStatus("Waiting for kubeflex operator to become ready...", done, &wg, chattyStatus)
util.WaitForDeploymentReady(
clientset,
Expand Down
4 changes: 3 additions & 1 deletion cmd/kflex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var Hook string
var domain string
var externalPort int
var chattyStatus bool
var hookVars []string

// defaults
const BKTypeDefault = string(tenancyv1alpha1.BackendDBTypeShared)
Expand Down Expand Up @@ -132,7 +133,7 @@ var createCmd = &cobra.Command{
BkType = BKTypeDefault
}
// create passing the control plane type and backend type
cp.Create(CType, BkType, Hook, chattyStatus)
cp.Create(CType, BkType, Hook, hookVars, chattyStatus)
},
}

Expand Down Expand Up @@ -194,6 +195,7 @@ func init() {
createCmd.Flags().StringVarP(&BkType, "backend-type", "b", "", "backend DB sharing: shared|dedicated")
createCmd.Flags().StringVarP(&Hook, "postcreate-hook", "p", "", "name of post create hook to run")
createCmd.Flags().BoolVarP(&chattyStatus, "chatty-status", "s", true, "chatty status indicator")
createCmd.Flags().StringArrayVarP(&hookVars, "set", "e", []string{}, "set post create hook variables, in the form name=value ")

deleteCmd.Flags().StringVarP(&kubeconfig, "kubeconfig", "k", "", "path to kubeconfig file")
deleteCmd.Flags().IntVarP(&verbosity, "verbosity", "v", 0, "log level") // TODO - figure out how to inject verbosity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ spec:
type: string
postCreateHook:
type: string
postCreateHookVars:
additionalProperties:
type: string
type: object
type:
enum:
- k8s
Expand Down
5 changes: 5 additions & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ spec:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
env:
- name: HELM_CONFIG_HOME
value: /tmp
- name: HELM_CACHE_HOME
value: /tmp
6 changes: 3 additions & 3 deletions config/samples/postcreate-hooks/openshift-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: "{{.HookName}}"
image: quay.io/pdettori/helm:v3.13.2
image: quay.io/kubestellar/helm:3.14.0
args:
- upgrade
- --install
Expand All @@ -25,11 +25,11 @@ spec:
- "0.1.0"
env:
- name: KUBECONFIG
value: "/etc/kube/kubeconfig-incluster"
value: "/etc/kube/kubeconfig-incluster"
volumeMounts:
- name: kubeconfig
mountPath: "/etc/kube"
readOnly: true
readOnly: true
volumes:
- name: kubeconfig
secret:
Expand Down
6 changes: 3 additions & 3 deletions config/samples/postcreate-hooks/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- create
- list
- update
- apiVersion: rbac.authorization.k8s.io/v1
- apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: "{{.HookName}}"
Expand All @@ -37,7 +37,7 @@ spec:
subjects:
- kind: ServiceAccount
name: default
namespace: "{{.Namespace}}"
namespace: "{{.Namespace}}"
- apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -47,7 +47,7 @@ spec:
spec:
containers:
- name: "{{.HookName}}"
image: quay.io/pdettori/helm:v3.13.2
image: quay.io/kubestellar/helm:3.14.0
args:
- upgrade
- --install
Expand Down
Loading

0 comments on commit a7d96b7

Please sign in to comment.