mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Maintenance Mode (#516)
This commit is contained in:
parent
59277df79e
commit
9b73a77d3e
6 changed files with 54 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
|||
# Change Log
|
||||
|
||||
## Master
|
||||
- Add Maintenance mode annotation for ArangoDeployment
|
||||
|
||||
## [0.4.2](https://github.com/arangodb/kube-arangodb/tree/0.4.2) (2019-11-12)
|
||||
- AntiAffinity for operator pods.
|
||||
- Add CRD API v1 with support for v1alpha.
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
- [Scaling](./scaling.md)
|
||||
- [Status](./status.md)
|
||||
- [Upgrading](./upgrading.md)
|
||||
- [Maintenance](./maintenance.md)
|
14
docs/design/maintenance.md
Normal file
14
docs/design/maintenance.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Maintenance
|
||||
|
||||
## ArangoDeployment
|
||||
|
||||
Maintenance on ArangoDeployment can be enabled using annotation.
|
||||
|
||||
Key: `deployment.arangodb.com/maintenance`
|
||||
Value: `true`
|
||||
|
||||
To enable maintenance mode for ArangoDeployment kubectl command can be used:
|
||||
`kubectl annotate arangodeployment deployment deployment.arangodb.com/maintenance=true`
|
||||
|
||||
To disable maintenance mode for ArangoDeployment kubectl command can be used:
|
||||
`kubectl annotate --overwrite arangodeployment deployment deployment.arangodb.com/maintenance-`
|
2
go.mod
2
go.mod
|
@ -55,7 +55,7 @@ require (
|
|||
github.com/helm/helm v2.14.3+incompatible // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
|
||||
github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f // indirect
|
||||
github.com/jessevdk/go-assets-builder v0.0.0-20130903091706-b8483521738f
|
||||
github.com/jessevdk/go-flags v1.4.0 // indirect
|
||||
github.com/jonboulle/clockwork v0.1.0 // indirect
|
||||
github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect
|
||||
|
|
|
@ -37,6 +37,10 @@ var (
|
|||
inspectDeploymentDurationGauges = metrics.MustRegisterGaugeVec(metricsComponent, "inspect_deployment_duration", "Amount of time taken by a single inspection of a deployment (in sec)", metrics.DeploymentName)
|
||||
)
|
||||
|
||||
const (
|
||||
arangoDeploymentMaintenanceAnnotation = "deployment.arangodb.com/maintenance"
|
||||
)
|
||||
|
||||
// inspectDeployment inspects the entire deployment, creates
|
||||
// a plan to update if needed and inspects underlying resources.
|
||||
// This function should be called when:
|
||||
|
@ -68,6 +72,14 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
|
|||
d.CreateEvent(k8sutil.NewErrorEvent("ArangoDeployment finalizer inspection failed", err, d.apiObject))
|
||||
}
|
||||
} else {
|
||||
// Check if maintenance annotation is set
|
||||
if updated != nil && updated.Annotations != nil {
|
||||
if v, ok := updated.Annotations[arangoDeploymentMaintenanceAnnotation]; ok && v == "true" {
|
||||
// Disable checks if we will enter maintenance mode
|
||||
log.Info().Str("deployment", deploymentName).Msg("Deployment in maintenance mode")
|
||||
return nextInterval
|
||||
}
|
||||
}
|
||||
// Is the deployment in failed state, if so, give up.
|
||||
if d.GetPhase() == api.DeploymentPhaseFailed {
|
||||
log.Debug().Msg("Deployment is in Failed state.")
|
||||
|
|
23
tools/tools.go
Normal file
23
tools/tools.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed 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.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package tools
|
||||
|
||||
import _ "github.com/jessevdk/go-assets-builder"
|
Loading…
Reference in a new issue