-
Notifications
You must be signed in to change notification settings - Fork 127
Review snapshots and daemonsets #201
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
package k8sutil | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Sirupsen/logrus" | ||
"k8s.io/api/core/v1" | ||
"k8s.io/api/extensions/v1beta1" | ||
|
@@ -36,14 +38,28 @@ const ( | |
esOperatorSysctlName = "elasticsearch-operator-sysctl" | ||
) | ||
|
||
// DeleteNodeInitDaemonset delete the node init daemonset | ||
func (k *K8sutil) DeleteNodeInitDaemonset(namespace string) error { | ||
|
||
ds, err := k.Kclient.ExtensionsV1beta1().DaemonSets(namespace).Get(esOperatorSysctlName, metav1.GetOptions{}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the |
||
|
||
if err != nil { | ||
return fmt.Errorf("Could not delete daemonset: %s ", ds.Name) | ||
} | ||
|
||
logrus.Infof("Deleted daemonset: %s", ds.Name) | ||
return nil | ||
|
||
} | ||
|
||
// CreateNodeInitDaemonset creates the node init daemonset | ||
func (k *K8sutil) CreateNodeInitDaemonset(namespace string) error { | ||
|
||
ds, err := k.Kclient.ExtensionsV1beta1().DaemonSets(namespace).Get(esOperatorSysctlName, metav1.GetOptions{}) | ||
|
||
if err != nil && len(ds.Name) == 0 { | ||
|
||
logrus.Infof("Daemonset %s not found, creating...", ds) | ||
logrus.Infof("Daemonset %s not found, creating...", ds.Name) | ||
|
||
resourceCPU, _ := resource.ParseQuantity("10m") | ||
resourceMemory, _ := resource.ParseQuantity("50Mi") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,7 +158,7 @@ func newKubeClient(kubeCfgFile string) (genclient.Interface, kubernetes.Interfac | |
} | ||
|
||
// CreateKubernetesCustomResourceDefinition checks if ElasticSearch CRD exists. If not, create | ||
func (k *K8sutil) CreateKubernetesCustomResourceDefinition() error { | ||
func (k *K8sutil) CreateKubernetesCustomResourceDefinition() (*apiextensionsv1beta1.CustomResourceDefinition, error) { | ||
|
||
crd, err := k.KubeExt.ApiextensionsV1beta1().CustomResourceDefinitions().Get(elasticsearchoperator.Name, metav1.GetOptions{}) | ||
if err != nil { | ||
|
@@ -208,9 +208,9 @@ func (k *K8sutil) CreateKubernetesCustomResourceDefinition() error { | |
if err != nil { | ||
deleteErr := k.KubeExt.ApiextensionsV1beta1().CustomResourceDefinitions().Delete(elasticsearchoperator.Name, nil) | ||
if deleteErr != nil { | ||
return errors.NewAggregate([]error{err, deleteErr}) | ||
return nil, errors.NewAggregate([]error{err, deleteErr}) | ||
} | ||
return err | ||
return nil, err | ||
} | ||
|
||
logrus.Info("CRD ready!") | ||
|
@@ -221,7 +221,7 @@ func (k *K8sutil) CreateKubernetesCustomResourceDefinition() error { | |
logrus.Infof("SKIPPING: already exists %#v\n", crd.ObjectMeta.Name) | ||
} | ||
|
||
return nil | ||
return crd, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be: |
||
} | ||
|
||
// MonitorElasticSearchEvents watches for new or removed clusters | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting this error:
CRD does not have a namespace as it is cluster-wide.
Would this work to just create it in the same namespace as the controller?