Commit 7b7feb01 authored by Edmund Ochieng's avatar Edmund Ochieng

Merge branch 'bundle_update' into 'master'

Update bundle base bundle

See merge request !16
parents eb49d694 ad5bdaa0
Pipeline #187443983 passed with stages
in 11 minutes and 9 seconds
......@@ -76,4 +76,6 @@ tags
.history
# Local build tools
Makefile
controllers/suite_test.go
config/local
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
......@@ -23,29 +23,32 @@ import (
// GitLabSpec defines the desired state of GitLab
type GitLabSpec struct {
Release string `json:"release,omitempty"`
URL string `json:"url,omitempty"`
TLS string `json:"tls,omitempty"`
SMTP SMTPConfiguration `json:"smtp,omitempty"`
Registry RegistrySpec `json:"registry,omitempty"`
ObjectStore ObjectStoreSpec `json:"objectStore,omitempty"`
Redis *RedisSpec `json:"redis,omitempty"`
Database *DatabaseSpec `json:"postgresql,omitempty"`
CertIssuer *ACMEOptions `json:"acme,omitempty"`
Volumes ComponentVolumeSpec `json:"volumes,omitempty"`
Release string `json:"release,omitempty"`
URL string `json:"url,omitempty"`
TLS string `json:"tls,omitempty"`
SMTP SMTPConfiguration `json:"smtp,omitempty"`
Registry RegistrySpec `json:"registry,omitempty"`
ObjectStore ObjectStoreSpec `json:"objectStore,omitempty"`
Redis *RedisSpec `json:"redis,omitempty"`
Database *DatabaseSpec `json:"postgres,omitempty"`
CertIssuer *ACMEOptions `json:"acme,omitempty"`
// Volume for Gitaly statefulset
Volume VolumeSpec `json:"volume,omitempty"`
}
// RedisSpec defines Redis options
type RedisSpec struct {
Replicas int32 `json:"replicas,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
Volume VolumeSpec `json:"volume,omitempty"`
}
// DatabaseSpec defines database options
type DatabaseSpec struct {
Replicas int32 `json:"replicas,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
Volume VolumeSpec `json:"volume,omitempty"`
}
// RegistrySpec defines options for Gitlab registry
// RegistrySpec defines options for GitLab registry
type RegistrySpec struct {
Disabled bool `json:"disable,omitempty"`
URL string `json:"url,omitempty"`
......@@ -140,17 +143,6 @@ type VolumeSpec struct {
StorageClass string `json:"storageClass,omitempty"`
}
// ComponentVolumeSpec defines volumes for
// the different Gitlab peieces
type ComponentVolumeSpec struct {
// Postgres database volume for PGDATA
Postgres VolumeSpec `json:"database,omitempty"`
// Redis key value store volume
Redis VolumeSpec `json:"redis,omitempty"`
// Gitlab registry volume
Repositories VolumeSpec `json:"repositories,omitempty"`
}
// HealthCheck represents the status
// of services that make up Gitlab
type HealthCheck struct {
......
......@@ -52,27 +52,10 @@ func (in *ACMEOptions) DeepCopy() *ACMEOptions {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ComponentVolumeSpec) DeepCopyInto(out *ComponentVolumeSpec) {
*out = *in
out.Postgres = in.Postgres
out.Redis = in.Redis
out.Repositories = in.Repositories
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentVolumeSpec.
func (in *ComponentVolumeSpec) DeepCopy() *ComponentVolumeSpec {
if in == nil {
return nil
}
out := new(ComponentVolumeSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DatabaseSpec) DeepCopyInto(out *DatabaseSpec) {
*out = *in
out.Volume = in.Volume
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatabaseSpec.
......@@ -254,7 +237,7 @@ func (in *GitLabSpec) DeepCopyInto(out *GitLabSpec) {
*out = new(ACMEOptions)
(*in).DeepCopyInto(*out)
}
out.Volumes = in.Volumes
out.Volume = in.Volume
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabSpec.
......@@ -335,6 +318,7 @@ func (in *ObjectStoreSpec) DeepCopy() *ObjectStoreSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
*out = *in
out.Volume = in.Volume
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisSpec.
......
......@@ -22,10 +22,14 @@ spec:
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
......@@ -36,10 +40,12 @@ spec:
description: Instance represents the 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 ID: will
be restored to the gitlab instance'
type: boolean
schedule:
description: Schedule defines the time and day to run backup It takes cron time format
description: Schedule defines the time and day to run backup It takes
cron time format
type: string
skip:
description: Exclusions allows user to exclude components to backup
......
......@@ -20,10 +20,14 @@ spec:
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
......@@ -53,7 +57,8 @@ 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
......@@ -66,7 +71,8 @@ spec:
description: Tags passes the runner tags
type: string
token:
description: RegistrationToken is name of secret with the runner-registration-token key used to register the runner
description: RegistrationToken is name of secret with the runner-registration-token
key used to register the runner
type: string
type: object
status:
......
......@@ -23,24 +23,26 @@ metadata:
"name": "example"
},
"spec": {
"objectStore": {
"development": true
},
"registry": {
"url": "registry.example.com"
},
"url": "gitlab.example.com",
"volumes": {
"database": {
"capacity": "8Gi"
"url": "gitlab.example.com",
"volume": {
"capacity": "10Gi"
},
"registry": {
"url": "registry.example.com"
},
"objectStore": {
"development": true
},
"redis": {
"capacity": "4Gi"
"volume": {
"capacity": "4Gi"
}
},
"repositories": {
"capacity": "10Gi"
"postgres": {
"volume": {
"capacity": "8Gi"
}
}
}
}
},
{
......@@ -112,11 +114,6 @@ spec:
path: tls
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: Disable Registry defines if the GitLab container registry should be deployed
displayName: Disable Registry
path: registry.disable
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: Registry URL defines address at through which the GitLab registry can be reached
displayName: Registry URL
path: registry.url
......@@ -127,6 +124,21 @@ spec:
path: registry.tls
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:selector:core:v1:Secret
- description: The volume capacity for the Redis volume e.g. 20Gi
displayName: Redis Volume
path: redis.volume.capacity
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: The volume capacity for the Postgresql volume e.g. 20Gi
displayName: Postgresql Volume
path: postgres.volume.capacity
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: The volume capacity for the repository volume e.g. 20Gi
displayName: Repository Volume
path: volume.capacity
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
statusDescriptors:
- description: Phase defines the state of the GitLab instance
displayName: Status
......
......@@ -1560,12 +1560,22 @@ spec:
reach the minio deployment
type: string
type: object
postgresql:
postgres:
description: DatabaseSpec defines database options
properties:
replicas:
format: int32
type: integer
volume:
description: VolumeSpec defines volume specifications
properties:
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
type: object
redis:
description: RedisSpec defines Redis options
......@@ -1573,9 +1583,19 @@ spec:
replicas:
format: int32
type: integer
volume:
description: VolumeSpec defines volume specifications
properties:
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
type: object
registry:
description: RegistrySpec defines options for Gitlab registry
description: RegistrySpec defines options for GitLab registry
properties:
disable:
type: boolean
......@@ -1635,40 +1655,15 @@ spec:
type: string
url:
type: string
volumes:
description: ComponentVolumeSpec defines volumes for the different Gitlab
peieces
volume:
description: Volume for Gitaly statefulset
properties:
database:
description: Postgres database volume for PGDATA
properties:
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
redis:
description: Redis key value store volume
properties:
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
repositories:
description: Gitlab registry volume
properties:
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
capacity:
description: Capacity of the volume
type: string
storageClass:
description: StorageClass from which volume should originate
type: string
type: object
type: object
status:
......
......@@ -32,7 +32,7 @@ spec:
- --enable-leader-election
command:
- /manager
image: quay.io/eochieng/gitlab-operator:latest
image: registry.gitlab.com/gitlab-org/gl-openshift/gitlab-operator:latest
name: manager
env:
- name: WATCH_NAMESPACE
......
......@@ -4,14 +4,15 @@ metadata:
name: example
spec:
url: gitlab.example.com
volume:
capacity: 10Gi
registry:
url: registry.example.com
objectStore:
development: true
volumes:
database:
capacity: 8Gi
redis:
redis:
volume:
capacity: 4Gi
repositories:
capacity: 10Gi
postgres:
volume:
capacity: 8Gi
......@@ -37,8 +37,8 @@ func PostgresStatefulSet(cr *gitlabv1beta1.GitLab) *appsv1.StatefulSet {
}
// Mount volume is specified
if cr.Spec.Volumes.Postgres.Capacity != "" {
volumeSize := cr.Spec.Volumes.Postgres.Capacity
if cr.Spec.Database.Volume.Capacity != "" {
volumeSize := cr.Spec.Database.Volume.Capacity
claims = append(claims, corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: "data",
......@@ -334,8 +334,8 @@ func RedisStatefulSet(cr *gitlabv1beta1.GitLab) *appsv1.StatefulSet {
},
}
if cr.Spec.Volumes.Redis.Capacity != "" {
volumeSize := cr.Spec.Volumes.Redis.Capacity
if cr.Spec.Redis.Volume.Capacity != "" {
volumeSize := cr.Spec.Redis.Volume.Capacity
claims = append(claims, corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: "data",
......@@ -522,7 +522,7 @@ func GitalyStatefulSet(cr *gitlabv1beta1.GitLab) *appsv1.StatefulSet {
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"storage": gitlabutils.ResourceQuantity(cr.Spec.Volumes.Repositories.Capacity),
"storage": gitlabutils.ResourceQuantity(cr.Spec.Volume.Capacity),
},
},
},
......
......@@ -10,7 +10,6 @@ import (
"strings"
"text/template"
"github.com/prometheus/common/log"
gitlabv1beta1 "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/api/v1beta1"
gitlabutils "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/controllers/utils"
corev1 "k8s.io/api/core/v1"
......@@ -48,30 +47,6 @@ func hasTLS(cr *gitlabv1beta1.GitLab) bool {
return cr.Spec.TLS != ""
}
// IsEndpointReady checks if kubernetes endpoint is ready to accept connections.
// Watches endpoint for pod IP address
func IsEndpointReady(service string, cr *gitlabv1beta1.GitLab) bool {
var addresses []corev1.EndpointAddress
client, err := gitlabutils.KubernetesConfig().NewKubernetesClient()
if err != nil {
log.Error(err, "Unable to acquire client")
}
endpoint, err := client.CoreV1().Endpoints(cr.Namespace).Get(context.TODO(), service, metav1.GetOptions{})
if err != nil {
// Endpoint was not found so return false
return false
}
for _, subset := range endpoint.Subsets {
addresses = append(addresses, subset.Addresses...)
}
// If more than one IP address is returned,
// The database is up and listening for connections
return len(addresses) > 0
}
// The database endpoint returns the gitlab database endpoint
// Function is used by other functions e.g. isDatabaseReady
func getOperatorMetricsEndpoints(cr *gitlabv1beta1.GitLab) (*corev1.Endpoints, error) {
......
......@@ -18,7 +18,6 @@ package controllers
import (
"context"
"sync"
"time"
"github.com/go-logr/logr"
......@@ -69,6 +68,7 @@ func (r *GitLabReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
log := r.Log.WithValues("gitlab", req.NamespacedName)
log.Info("Reconciling GitLab object", "Name", req.NamespacedName.Name)
gitlab := &gitlabv1beta1.GitLab{}
if err := r.Get(ctx, req.NamespacedName, gitlab); err != nil {
if errors.IsNotFound(err) {
......@@ -99,23 +99,16 @@ func (r *GitLabReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, err
}
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
for !gitlabctl.IsEndpointReady(gitlab.Name+"-postgresql", gitlab) {
time.Sleep(time.Second * 1)
}
wg.Done()
}()
if gitlabctl.RequiresCertManagerCertificate(gitlab).All() {
if err := r.reconcileCertManagerCertificates(gitlab); err != nil {
return ctrl.Result{}, err
}
}
wg.Wait()
waitInterval := 5 * time.Second
if !r.ifCoreServicesReady(ctx, gitlab) {
return ctrl.Result{RequeueAfter: waitInterval}, nil
}
if err := r.reconcileJobs(gitlab); err != nil {
return ctrl.Result{}, err
......
package controllers
import (
"context"
gitlabv1beta1 "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/api/v1beta1"
gitlabutils "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/controllers/utils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
......@@ -23,3 +28,25 @@ func (r *RunnerReconciler) isObjectFound(object interface{}) bool {
func (r *GLBackupReconciler) isObjectFound(object interface{}) bool {
return gitlabutils.IsObjectFound(r.Client, getNamespacedName(object), object.(runtime.Object))
}
func (r *GitLabReconciler) isEndpointReady(ctx context.Context, service string, cr *gitlabv1beta1.GitLab) bool {
var addresses []corev1.EndpointAddress
ep := &corev1.Endpoints{}
err := r.Get(ctx, types.NamespacedName{Name: service, Namespace: cr.Namespace}, ep)
if err != nil && errors.IsNotFound(err) {
return false
}
for _, subset := range ep.Subsets {
addresses = append(addresses, subset.Addresses...)
}
return len(addresses) > 0
}
func (r *GitLabReconciler) ifCoreServicesReady(ctx context.Context, cr *gitlabv1beta1.GitLab) bool {
return r.isEndpointReady(ctx, cr.Name+"-postgresql", cr) &&
r.isEndpointReady(ctx, cr.Name+"-gitaly", cr) &&
r.isEndpointReady(ctx, cr.Name+"-redis", cr)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment