Skip to content

Commit

Permalink
[BOP-12] Support for adding AddOns via Manifest (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshisharma84 authored Nov 13, 2023
1 parent 317f67a commit 35abe6e
Show file tree
Hide file tree
Showing 22 changed files with 987 additions and 53 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ resources:
kind: Ingress
path: github.com/mirantis/boundless-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mirantis.com
group: boundless
kind: Manifest
path: github.com/mirantis/boundless-operator/api/v1alpha1
version: v1alpha1
version: "3"
17 changes: 11 additions & 6 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ type AddonSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Name string `json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Namespace string `json:"namespace,omitempty"`
Chart Chart `json:"chart"`
Name string `json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Namespace string `json:"namespace,omitempty"`
Chart ChartInfo `json:"chart,omitempty"`
Manifest ManifestInfo `json:"manifest,omitempty"`
}

type Chart struct {
type ChartInfo struct {
Name string `json:"name"`
Repo string `json:"repo"`
Version string `json:"version"`
Set map[string]intstr.IntOrString `json:"set,omitempty"`
Values string `json:"values,omitempty"`
}

type ManifestInfo struct {
URL string `json:"url"`
}

// AddonStatus defines the observed state of Addon
type AddonStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down
48 changes: 48 additions & 0 deletions api/v1alpha1/manifest_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// ManifestSpec defines the desired state of Manifest
type ManifestSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of Manifest. Edit manifest_types.go to remove/update
Url string `json:"url,omitempty"`
}

// ManifestStatus defines the observed state of Manifest
type ManifestStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Manifest is the Schema for the manifests API
type Manifest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ManifestSpec `json:"spec,omitempty"`
Status ManifestStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ManifestList contains a list of Manifest
type ManifestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Manifest `json:"items"`
}

func init() {
SchemeBuilder.Register(&Manifest{}, &ManifestList{})
}
113 changes: 109 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 7 additions & 1 deletion config/crd/bases/boundless.mirantis.com_addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ spec:
type: boolean
kind:
type: string
manifest:
properties:
url:
type: string
required:
- url
type: object
name:
type: string
namespace:
type: string
required:
- chart
- enabled
- kind
- name
Expand Down
8 changes: 7 additions & 1 deletion config/crd/bases/boundless.mirantis.com_blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ spec:
type: boolean
kind:
type: string
manifest:
properties:
url:
type: string
required:
- url
type: object
name:
type: string
namespace:
type: string
required:
- chart
- enabled
- kind
- name
Expand Down
50 changes: 50 additions & 0 deletions config/crd/bases/boundless.mirantis.com_manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: manifests.boundless.mirantis.com
spec:
group: boundless.mirantis.com
names:
kind: Manifest
listKind: ManifestList
plural: manifests
singular: manifest
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: Manifest is the Schema for the manifests API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ManifestSpec defines the desired state of Manifest
properties:
url:
description: Foo is an example field of Manifest. Edit manifest_types.go
to remove/update
type: string
type: object
status:
description: ManifestStatus defines the observed state of Manifest
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resources:
- bases/boundless.mirantis.com_addons.yaml
- bases/boundless.mirantis.com_ingresses.yaml
- bases/boundless.mirantis.com_blueprints.yaml
- bases/boundless.mirantis.com_manifests.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand All @@ -14,6 +15,7 @@ patchesStrategicMerge:
#- patches/webhook_in_clusters.yaml
#- patches/webhook_in_ingresses.yaml
#- patches/webhook_in_blueprints.yaml
#- patches/webhook_in_manifests.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -22,6 +24,7 @@ patchesStrategicMerge:
#- patches/cainjection_in_clusters.yaml
#- patches/cainjection_in_ingresses.yaml
#- patches/cainjection_in_blueprints.yaml
#- patches/cainjection_in_manifests.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: manifests.boundless.mirantis.com
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: manifests.boundless.mirantis.com
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
6 changes: 6 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/mirantis/boundless-operator
newTag: manifest
Loading

0 comments on commit 35abe6e

Please sign in to comment.