Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CRDs V1 #2184

Merged
merged 16 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ issues:
text: 'ifElseChain: rewrite if\-else to switch statement'
- path: pkg/apis/elasticsearch/v1beta1/fields\.go
text: 'const .* should be'
- path: pkg/apis/elasticsearch/v1/fields\.go
text: 'const .* should be'
- path: pkg/controller/elasticsearch/user/reconciler\.go
text: 'Consider preallocating `allUsers`'
- path: pkg/controller/elasticsearch/user/user\.go
Expand All @@ -92,6 +94,8 @@ issues:
text: 'G101: Potential hardcoded credentials'
- path: pkg/apis/elasticsearch/v1beta1/name\.go
text: 'G101: Potential hardcoded credentials'
- path: pkg/apis/elasticsearch/v1/name\.go
text: 'G101: Potential hardcoded credentials'
- path: pkg/controller/elasticsearch/driver/version\.go
text: 'Consider preallocating `vs`'
- linters:
Expand Down
31 changes: 16 additions & 15 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ import (
// allow gcp authentication
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/elastic/cloud-on-k8s/pkg/about"
apmtype "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1beta1"
estype "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1beta1"
kibanatype "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1beta1"
apmv1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1"
esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1"
kbv1 "github.com/elastic/cloud-on-k8s/pkg/apis/kibana/v1"
"github.com/elastic/cloud-on-k8s/pkg/controller/apmserver"
asesassn "github.com/elastic/cloud-on-k8s/pkg/controller/apmserverelasticsearchassociation"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/association"
Expand All @@ -36,15 +46,6 @@ import (
"github.com/elastic/cloud-on-k8s/pkg/dev"
"github.com/elastic/cloud-on-k8s/pkg/dev/portforward"
"github.com/elastic/cloud-on-k8s/pkg/utils/net"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

const (
Expand Down Expand Up @@ -349,8 +350,8 @@ func garbageCollectUsers(cfg *rest.Config, managedNamespaces []string) {
os.Exit(1)
}
err = ugc.
For(&apmtype.ApmServerList{}, asesassn.AssociationLabelNamespace, asesassn.AssociationLabelName).
For(&kibanatype.KibanaList{}, kbassn.AssociationLabelNamespace, kbassn.AssociationLabelName).
For(&apmv1.ApmServerList{}, asesassn.AssociationLabelNamespace, asesassn.AssociationLabelName).
For(&kbv1.KibanaList{}, kbassn.AssociationLabelNamespace, kbassn.AssociationLabelName).
DoGarbageCollection()
if err != nil {
log.Error(err, "user garbage collector failed")
Expand Down Expand Up @@ -382,7 +383,7 @@ func setupWebhook(mgr manager.Manager, certRotation certificates.RotationParams,
}
}

if err := (&estype.Elasticsearch{}).SetupWebhookWithManager(mgr); err != nil {
if err := (&esv1.Elasticsearch{}).SetupWebhookWithManager(mgr); err != nil {
log.Error(err, "unable to create webhook", "webhook", "Elasticsearch")
os.Exit(1)
}
Expand Down
21 changes: 15 additions & 6 deletions config/crds/all-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,14 @@ spec:
connect to.
type: string
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
- name: v1alpha1
served: false
storage: false
Expand Down Expand Up @@ -1084,11 +1087,14 @@ spec:
is in from the controller point of view.
type: string
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
- name: v1alpha1
served: false
storage: false
Expand Down Expand Up @@ -1465,11 +1471,14 @@ spec:
description: KibanaHealth expresses the status of the Kibana instances.
type: string
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
- name: v1alpha1
served: false
storage: false
Expand Down
7 changes: 5 additions & 2 deletions config/crds/bases/apm.k8s.elastic.co_apmservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4566,11 +4566,14 @@ spec:
type: string
type: object
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5181,11 +5181,14 @@ spec:
type: string
type: object
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
7 changes: 5 additions & 2 deletions config/crds/bases/kibana.k8s.elastic.co_kibanas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4555,11 +4555,14 @@ spec:
type: string
type: object
type: object
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
- name: v1beta1
served: true
storage: false
status:
acceptedNames:
kind: ""
Expand Down
19 changes: 19 additions & 0 deletions config/e2e/global_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,25 @@ webhooks:
- UPDATE
resources:
- elasticsearches
- clientConfig:
caBundle: Cg==
service:
name: elastic-webhook-server
namespace: {{ .GlobalOperator.Namespace }}
# this is the path controller-runtime automatically generates
path: /validate-elasticsearch-k8s-elastic-co-v1-elasticsearch
failurePolicy: Ignore
name: elastic-es-validation.k8s.elastic.co
rules:
- apiGroups:
- elasticsearch.k8s.elastic.co
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- elasticsearches
---
apiVersion: v1
kind: Service
Expand Down
19 changes: 19 additions & 0 deletions config/operator/global/webhook.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ kind: ValidatingWebhookConfiguration
metadata:
name: elastic-webhook.k8s.elastic.co
webhooks:
- clientConfig:
caBundle: Cg==
service:
name: elastic-webhook-server
namespace: <NAMESPACE>
# this is the path controller-runtime automatically generates
path: /validate-elasticsearch-k8s-elastic-co-v1-elasticsearch
failurePolicy: Ignore
name: elastic-es-validation.k8s.elastic.co
rules:
- apiGroups:
- elasticsearch.k8s.elastic.co
apiVersions:
- v1
sebgl marked this conversation as resolved.
Show resolved Hide resolved
operations:
- CREATE
- UPDATE
resources:
- elasticsearches
- clientConfig:
caBundle: Cg==
service:
Expand Down
4 changes: 2 additions & 2 deletions config/recipes/beats/1_monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This sample sets up an Elasticsearch cluster and a Kibana instance preconfigured for that cluster
apiVersion: elasticsearch.k8s.elastic.co/v1beta1
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: monitor
Expand All @@ -24,7 +24,7 @@ spec:
requests:
storage: 50Gi
---
apiVersion: kibana.k8s.elastic.co/v1beta1
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: monitor
Expand Down
6 changes: 3 additions & 3 deletions config/samples/apm/apm_es_kibana.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This sample sets up a an Elasticsearch cluster along with a Kibana instance
# and an APM server, configured to be able to communicate with each other
apiVersion: elasticsearch.k8s.elastic.co/v1beta1
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: es-apm-sample
Expand All @@ -14,7 +14,7 @@ spec:
# See: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
node.store.allow_mmap: false
---
apiVersion: apm.k8s.elastic.co/v1beta1
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
name: apm-apm-sample
Expand All @@ -24,7 +24,7 @@ spec:
elasticsearchRef:
name: "es-apm-sample"
---
apiVersion: kibana.k8s.elastic.co/v1beta1
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: kb-apm-sample
Expand Down
2 changes: 1 addition & 1 deletion config/samples/apm/apmserver.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apm.k8s.elastic.co/v1beta1
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
name: apmserver-sample
Expand Down
2 changes: 1 addition & 1 deletion config/samples/elasticsearch/elasticsearch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This sample sets up an Elasticsearch cluster with 3 nodes.
apiVersion: elasticsearch.k8s.elastic.co/v1beta1
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: elasticsearch-sample
Expand Down
4 changes: 2 additions & 2 deletions config/samples/kibana/kibana_es.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This sample sets up an Elasticsearch cluster and a Kibana instance preconfigured for that cluster
apiVersion: elasticsearch.k8s.elastic.co/v1beta1
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: elasticsearch-sample
Expand All @@ -13,7 +13,7 @@ spec:
# See: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
node.store.allow_mmap: false
---
apiVersion: kibana.k8s.elastic.co/v1beta1
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: kibana-sample
Expand Down
20 changes: 19 additions & 1 deletion config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,25 @@ webhooks:
service:
name: webhook-service
namespace: system
path: /validate-elasticsearch
path: /validate-elasticsearch-k8s-elastic-co-v1-elasticsearch
failurePolicy: Ignore
name: elastic-es-validation.k8s.elastic.co
rules:
- apiGroups:
- elasticsearch.k8s.elastic.co
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- elasticsearches
- clientConfig:
caBundle: Cg==
service:
name: webhook-service
namespace: system
path: /validate-elasticsearch-k8s-elastic-co-v1beta1-elasticsearch
failurePolicy: Ignore
name: elastic-es-validation.k8s.elastic.co
rules:
Expand Down
Loading