Commit 3ff7f606 authored by Edmund Ochieng's avatar Edmund Ochieng

Merge branch 'manifest' into 'master'

Add spec and status descriptors

See merge request !21
parents 3f3d98d8 0bbdd65b
Pipeline #190733042 passed with stages
in 11 minutes and 20 seconds
# Generated manager Golang binary
bin/manager
config/manifests/*.yaml
# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
### Emacs ###
# -*- mode: gitignore; -*-
......
......@@ -112,14 +112,10 @@ bundle: manifests
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
find bundle/manifests/ -type f | xargs -n 1 sed -i '/namespace: .*/d'
operator-sdk bundle validate ./bundle
# Build the bundle image.
.PHONY: bundle-build
bundle-build:
podman build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
# Generate install manifests
deploy-manifests:
rm -f config/manifests/*.yaml
kustomize build --output config/manifests config/default
......@@ -23,8 +23,16 @@ import (
// GitLabSpec defines the desired state of GitLab
type GitLabSpec struct {
Release string `json:"release,omitempty"`
URL string `json:"url,omitempty"`
// The GitLab version to deploy
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Release",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Release string `json:"release,omitempty"`
// The URL through which to access GitLab instance
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="GitLab URL",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
URL string `json:"url,omitempty"`
// Name of tls secret used to secure the GitLab instance
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="TLS Certificate",xDescriptors="urn:alm:descriptor:com.tectonic.ui:selector:core:v1:Secret"
TLS string `json:"tls,omitempty"`
SMTP SMTPConfiguration `json:"smtp,omitempty"`
Registry RegistrySpec `json:"registry,omitempty"`
......@@ -111,11 +119,14 @@ type SMTPConfiguration struct {
// AutoScalingSpec are the parameters to configure autoscaling
type AutoScalingSpec struct {
// MinReplicas is the lower limit to scale down to
// Minimum number of replicas to scale to
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Minimum Replicas",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
MinReplicas *int32 `json:"minReplicas,omitempty"`
// MaxReplicas is the upper limit to scale up to
// Maximum number of replicas to scale to
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Maxiumum Replicas",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
MaxReplicas int32 `json:"maxReplicas,omitempty"`
// TargetCPU is the CPU utilization threshold percentage
// Percentage CPU mark at which autoscaling triggers
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="CPU Percentage Threshold",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
TargetCPU *int32 `json:"targetCPU,omitempty"`
}
......@@ -149,8 +160,10 @@ type ACMEOptions struct {
// VolumeSpec defines volume specifications
type VolumeSpec struct {
// Capacity of the volume
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Storage capacity",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Capacity string `json:"capacity,omitempty"`
// StorageClass from which volume should originate
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Storage class",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
StorageClass string `json:"storageClass,omitempty"`
}
......@@ -174,6 +187,9 @@ type GitLabStatus struct {
// +kubebuilder:resource:shortName=gl
// +kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:displayName="GitLab"
// +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""},{Secret,v1,""},{Service,v1,""},{Pod,v1,""},{Deployment,v1,""},{StatefulSet,v1,""},{PersistentVolumeClaim,v1,""},{Runner,v1beta1,""},{GLBackup,v1beta1,""}}
// GitLab is the Schema for the gitlabs API
type GitLab struct {
metav1.TypeMeta `json:",inline"`
......
......@@ -22,24 +22,30 @@ import (
// GLBackupSpec defines the desired state of GLBackup
type GLBackupSpec struct {
// Instance represents the GitLab instance to backup
// Name of GitLab instance to backup
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="GitLab Name",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Instance string `json:"instance"`
// Schedule defines the time and day to run backup
// It takes cron time format
// Backup schedule in cron format.
// Leave blank for one time on-demand backup
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Schedule",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Schedule string `json:"schedule,omitempty"`
// Exclusions allows user to exclude components to backup
// Comma separated list of components to omit from backup
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Exclusions",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Exclusions string `json:"skip,omitempty"`
// Timestamp defines the prefix of the backup job
// Prefix for the backup job
// Can be used when restoring backup
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Timestamp",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Timestamp string `json:"timestamp,omitempty"`
// URL defines the address of the backup job
// The URL of the backup resource to be restored
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup URL",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
URL string `json:"url,omitempty"`
// Restore when set to true the backup defined by
// ID: will be restored to the gitlab instance
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Restore",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Restore bool `json:"restore,omitempty"`
}
......@@ -62,13 +68,17 @@ const (
// GLBackupStatus defines the observed state of GLBackup
type GLBackupStatus struct {
// Reports status of backup task
// +kubebuilder:validation:Enum=Running;Completed;Scheduled;Failed
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Backup Status",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Phase BackupState `json:"phase,omitempty"`
// StartedAt returns time when backup was initiated
// Displays time the backup started
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Start Time",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
StartedAt string `json:"startedAt,omitempty"`
// Completed returns time backup terminated or completed
// Displays time the backup completed
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Completion Time",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
CompletedAt string `json:"completedAt,omitempty"`
}
......@@ -76,6 +86,9 @@ type GLBackupStatus struct {
// +kubebuilder:resource:shortName=gbk
// +kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:displayName="GitLab Backup"
// +operator-sdk:csv:customresourcedefinitions:resources={{Job,v1,""},{CronJob,v1beta1,""},{ConfigMap,v1,""}}
// GLBackup is the Schema for the glbackups API
type GLBackup struct {
metav1.TypeMeta `json:",inline"`
......
......@@ -25,10 +25,12 @@ type RunnerSpec struct {
// GitlabResource represents a Gitlab custom resource. Should
// only be used to reference Gitlab instance created by the operator
Gitlab GitlabInstanceSpec `json:"gitlab,omitempty"`
// RegistrationToken is name of secret with the
// runner-registration-token key used to register the runner
//Name of secret containing the runner-registration-token key used to register the runner
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Registration Token",xDescriptors="urn:alm:descriptor:com.tectonic.ui:selector:core:v1:Secret"
RegistrationToken string `json:"token,omitempty"`
// Tags passes the runner tags
// List of comma separated tags to be applied to the runner
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Tags",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Tags string `json:"tags,omitempty"`
// Cache defines an S3 compatible object store
......@@ -38,9 +40,11 @@ type RunnerSpec struct {
// GitlabInstanceSpec defines the Gitlab custom
// resource in the kubernetes
type GitlabInstanceSpec struct {
// Name of gitlab resource in kubernetes / openshift
// Name of GitLab instance created by the operator
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Instance Name",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Name string `json:"name,omitempty"`
// Gitlab or Continuous Integration URL
// URL of GitLab instance
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Instance URL",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
URL string `json:"url,omitempty"`
}
......@@ -68,13 +72,21 @@ type RunnerCacheSpec struct {
// RunnerStatus defines the observed state of Runner
type RunnerStatus struct {
Phase string `json:"phase,omitempty"`
// Reports status of the GitLab Runner instance
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Phase",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Phase string `json:"phase,omitempty"`
// Reports status of GitLab Runner registration
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Registration",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
Registration string `json:"registration,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:displayName="GitLab Runner"
// +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""},{Secret,v1,""},{Service,v1,""},{Replicasets,v1,""},{Pod,v1,""},{Deployment,v1,""},{PersistentVolumeClaim,v1,""}}
// Runner is the Schema for the runners API
type Runner struct {
metav1.TypeMeta `json:",inline"`
......
......@@ -11,25 +11,17 @@ spec:
kind: GLBackup
listKind: GLBackupList
plural: glbackups
shortNames:
- gbk
singular: glbackup
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: GLBackup is the Schema for the glbackups 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'
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'
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
......@@ -37,24 +29,22 @@ spec:
description: GLBackupSpec defines the desired state of GLBackup
properties:
instance:
description: Instance represents the GitLab instance to backup
description: Name of GitLab instance to backup
type: string
restore:
description: 'Restore when set to true the backup defined by ID: will
be restored to the gitlab instance'
description: Restore when set to true the backup defined by
type: boolean
schedule:
description: Schedule defines the time and day to run backup It takes
cron time format
description: Backup schedule in cron format. Leave blank for one time on-demand backup
type: string
skip:
description: Exclusions allows user to exclude components to backup
description: Comma separated list of components to omit from backup
type: string
timestamp:
description: Timestamp defines the prefix of the backup job
description: Prefix for the backup job Can be used when restoring backup
type: string
url:
description: URL defines the address of the backup job
description: The URL of the backup resource to be restored
type: string
required:
- instance
......@@ -63,10 +53,10 @@ spec:
description: GLBackupStatus defines the observed state of GLBackup
properties:
completedAt:
description: Completed returns time backup terminated or completed
description: Displays time the backup completed
type: string
phase:
description: BackupState informs of current backup state
description: Reports status of backup task
enum:
- Running
- Completed
......@@ -74,7 +64,7 @@ spec:
- Failed
type: string
startedAt:
description: StartedAt returns time when backup was initiated
description: Displays time the backup started
type: string
type: object
type: object
......
......@@ -13,21 +13,15 @@ spec:
plural: runners
singular: runner
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: Runner is the Schema for the runners 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'
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'
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
......@@ -57,30 +51,30 @@ spec:
type: string
type: object
gitlab:
description: GitlabResource represents a Gitlab custom resource. Should
only be used to reference Gitlab instance created by the operator
description: GitlabResource represents a Gitlab custom resource. Should only be used to reference Gitlab instance created by the operator
properties:
name:
description: Name of gitlab resource in kubernetes / openshift
description: Name of GitLab instance created by the operator
type: string
url:
description: Gitlab or Continuous Integration URL
description: URL of GitLab instance
type: string
type: object
tags:
description: Tags passes the runner tags
description: List of comma separated tags to be applied to the runner
type: string
token:
description: RegistrationToken is name of secret with the runner-registration-token
key used to register the runner
description: Name of secret containing the runner-registration-token key used to register the runner
type: string
type: object
status:
description: RunnerStatus defines the observed state of Runner
properties:
phase:
description: Reports status of the GitLab Runner instance
type: string
registration:
description: Reports status of GitLab Runner registration
type: string
type: object
type: object
......
......@@ -2,17 +2,13 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: gitlab-proxy-role
name: gitlab-app-role
rules:
- apiGroups:
- authentication.k8s.io
- security.openshift.io
resourceNames:
- anyuid
resources:
- tokenreviews
- securitycontextconstraints
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- use
......@@ -2,12 +2,11 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: gitlab-proxy-rolebinding
name: gitlab-app-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: gitlab-proxy-role
name: gitlab-app-role
subjects:
- kind: ServiceAccount
name: default
namespace: gitlab-operator
name: gitlab-app
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: null
name: gitlab-app
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: gitlab-backup-role
rules:
- apiGroups:
- ""
resources:
- secrets
- pods
- events
- services
- services/status
- services/proxy
- services/finalizers
- resourcequotas
- pods/attach
- pods/exec
- pods/log
- persistentvolumeclaims
- configmaps
verbs:
- create
- get
- list
- watch
- delete
- patch
- update
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- get
- update
- delete
- watch
- list
......@@ -2,12 +2,11 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: gitlab-manager-rolebinding
name: gitlab-backup-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: gitlab-manager-role
name: gitlab-backup-role
subjects:
- kind: ServiceAccount
name: default
namespace: gitlab-operator
name: gitlab-backup
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: null
name: gitlab-backup
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: gitlab-manager-role
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.gitlab.com
resources:
- gitlabs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.gitlab.com
resources:
- gitlabs/status
verbs:
- get
- patch
- update
- apiGroups:
- apps.gitlab.com
resources:
- glbackups
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.gitlab.com
resources:
- glbackups/status
verbs:
- get
- patch
- update
- apiGroups:
- apps.gitlab.com
resources:
- runners
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.gitlab.com
resources:
- runners/status
verbs:
- get
- patch
- update
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- cronjobs