Skip to content
GitLab
Next
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GitLab Operator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
26
Issues
26
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GitLab.org
OpenShift
GitLab Operator
Commits
ad5bdaa0
Commit
ad5bdaa0
authored
Sep 08, 2020
by
Edmund Ochieng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update bundle base bundle
parent
eb49d694
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1090 additions
and
337 deletions
+1090
-337
.gitignore
.gitignore
+2
-0
api/v1beta1/gitlab_types.go
api/v1beta1/gitlab_types.go
+16
-24
api/v1beta1/zz_generated.deepcopy.go
api/v1beta1/zz_generated.deepcopy.go
+3
-19
bundle/manifests/apps.gitlab.com_gitlabs.yaml
bundle/manifests/apps.gitlab.com_gitlabs.yaml
+943
-183
bundle/manifests/apps.gitlab.com_glbackups.yaml
bundle/manifests/apps.gitlab.com_glbackups.yaml
+10
-4
bundle/manifests/apps.gitlab.com_runners.yaml
bundle/manifests/apps.gitlab.com_runners.yaml
+10
-4
bundle/manifests/gitlab-operator.clusterserviceversion.yaml
bundle/manifests/gitlab-operator.clusterserviceversion.yaml
+31
-19
config/crd/bases/apps.gitlab.com_gitlabs.yaml
config/crd/bases/apps.gitlab.com_gitlabs.yaml
+30
-35
config/deploy/gitlab-operator-manager.yaml
config/deploy/gitlab-operator-manager.yaml
+1
-1
config/samples/apps_v1beta1_gitlab.yaml
config/samples/apps_v1beta1_gitlab.yaml
+7
-6
controllers/gitlab/statefulsets.go
controllers/gitlab/statefulsets.go
+5
-5
controllers/gitlab/utils.go
controllers/gitlab/utils.go
+0
-25
controllers/gitlab_controller.go
controllers/gitlab_controller.go
+5
-12
controllers/helpers.go
controllers/helpers.go
+27
-0
No files found.
.gitignore
View file @
ad5bdaa0
...
...
@@ -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
api/v1beta1/gitlab_types.go
View file @
ad5bdaa0
...
...
@@ -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 Git
l
ab registry
// RegistrySpec defines options for Git
L
ab 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
{
...
...
api/v1beta1/zz_generated.deepcopy.go
View file @
ad5bdaa0
...
...
@@ -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
.
Volume
s
=
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.
...
...
bundle/manifests/apps.gitlab.com_gitlabs.yaml
View file @
ad5bdaa0
This diff is collapsed.
Click to expand it.
bundle/manifests/apps.gitlab.com_glbackups.yaml
View file @
ad5bdaa0
...
...
@@ -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
...
...
bundle/manifests/apps.gitlab.com_runners.yaml
View file @
ad5bdaa0
...
...
@@ -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
:
...
...
bundle/manifests/gitlab-operator.clusterserviceversion.yaml
View file @
ad5bdaa0
...
...
@@ -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
...
...
config/crd/bases/apps.gitlab.com_gitlabs.yaml
View file @
ad5bdaa0
...
...
@@ -1560,12 +1560,22 @@ spec:
reach the minio deployment
type
:
string
type
:
object
postgres
ql
:
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 Git
l
ab registry
description
:
RegistrySpec defines options for Git
L
ab 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
:
...
...
config/deploy/gitlab-operator-manager.yaml
View file @
ad5bdaa0
...
...
@@ -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
...
...
config/samples/apps_v1beta1_gitlab.yaml
View file @
ad5bdaa0
...
...
@@ -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
controllers/gitlab/statefulsets.go
View file @
ad5bdaa0
...
...
@@ -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
.
Volume
s
.
Repositories
.
Capacity
),
"storage"
:
gitlabutils
.
ResourceQuantity
(
cr
.
Spec
.
Volume
.
Capacity
),
},
},
},
...
...
controllers/gitlab/utils.go
View file @
ad5bdaa0
...
...
@@ -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
)
{
...
...
controllers/gitlab_controller.go
View file @
ad5bdaa0
...
...
@@ -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
...
...
controllers/helpers.go
View file @
ad5bdaa0
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
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment