You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/11/12 08:00:46 UTC

[GitHub] [camel-k] astefanutti commented on a change in pull request #1787: Create PodDisruptionBudget for every integration

astefanutti commented on a change in pull request #1787:
URL: https://github.com/apache/camel-k/pull/1787#discussion_r521901045



##########
File path: deploy/operator-role-kubernetes.yaml
##########
@@ -47,6 +47,17 @@ rules:
   - patch
   - update
   - watch
+- apiGroups:
+  - "policy"

Review comment:
       Are the double quotes necessary?

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.

Review comment:
       `Pod` -> `PDB`

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod
+type podTrait struct {

Review comment:
       `pod` -> `pdb`

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod
+type podTrait struct {
+	BaseTrait      `property:",squash"`
+	MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+	MinAvailable   string `property:"min-available" json:"minAvailable,omitempty"`
+}
+
+func newPodTrait() Trait {

Review comment:
       `pod` -> `pdb`

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod

Review comment:
       `pod` -> `pdb`

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod
+type podTrait struct {
+	BaseTrait      `property:",squash"`
+	MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+	MinAvailable   string `property:"min-available" json:"minAvailable,omitempty"`
+}
+
+func newPodTrait() Trait {
+	return &podTrait{
+		BaseTrait: NewBaseTrait("pod", 900),

Review comment:
       `pod` -> `pdb`

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod
+type podTrait struct {
+	BaseTrait      `property:",squash"`
+	MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+	MinAvailable   string `property:"min-available" json:"minAvailable,omitempty"`
+}
+
+func newPodTrait() Trait {
+	return &podTrait{
+		BaseTrait: NewBaseTrait("pod", 900),
+	}
+}
+
+func (t *podTrait) Configure(e *Environment) (bool, error) {
+	if t.Enabled != nil && !*t.Enabled {
+		return false, nil
+	}
+
+	return e.IntegrationInPhase(
+		v1.IntegrationPhaseDeploying,
+		v1.IntegrationPhaseRunning,
+	), nil
+}
+
+func (t *podTrait) Apply(e *Environment) error {
+	pdb, err := t.generatePodDisruptionBudget(e)
+	if err != nil {
+		return err
+	}
+	if pdb != nil {
+		e.Resources.Add(pdb)
+	}
+
+	return nil
+}
+
+func (t *podTrait) generatePodDisruptionBudget(e *Environment) (*v1beta1.PodDisruptionBudget, error) {
+	if t.MaxUnavailable == "" && t.MinAvailable == "" {

Review comment:
       Would setting a default value if the trait is enabled be useful?

##########
File path: pkg/trait/pdb.go
##########
@@ -0,0 +1,107 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+	"fmt"
+	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"k8s.io/api/policy/v1beta1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The Pod trait allows to configure the PodDisruptionBudget resource.
+//
+// +camel-k:trait=pod
+type podTrait struct {
+	BaseTrait      `property:",squash"`
+	MaxUnavailable string `property:"max-unavailable" json:"maxUnavailable,omitempty"`
+	MinAvailable   string `property:"min-available" json:"minAvailable,omitempty"`
+}
+
+func newPodTrait() Trait {
+	return &podTrait{
+		BaseTrait: NewBaseTrait("pod", 900),
+	}
+}
+
+func (t *podTrait) Configure(e *Environment) (bool, error) {
+	if t.Enabled != nil && !*t.Enabled {

Review comment:
       Should the trait be disabled when `t.Enabled == nil`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org