-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { Construct } from 'constructs'; | ||
import { IntOrString, KubePodDisruptionBudget } from './imports/k8s'; | ||
|
||
export interface PloneBackendPDBOptions { | ||
/** | ||
* maxUnavailable specification | ||
* @default - none | ||
*/ | ||
readonly maxUnavailable?: number | string; | ||
|
||
/** | ||
* minAvailable specification. | ||
* @default 1 | ||
*/ | ||
readonly minAvailable?: number | string; | ||
|
||
/** | ||
* Selector label. | ||
*/ | ||
readonly selector_label: { [name: string]: string }; | ||
|
||
/** | ||
* Extra labels to associate with resources. | ||
* @default - none | ||
*/ | ||
readonly labels?: { [name: string]: string }; | ||
} | ||
|
||
export class PloneBackendPDB extends Construct { | ||
|
||
constructor(scope: Construct, id: string, options: PloneBackendPDBOptions) { | ||
super(scope, id); | ||
|
||
var maxUnavailable: IntOrString = IntOrString.fromString(''); // default value | ||
if (typeof maxUnavailable === 'number') { | ||
maxUnavailable = IntOrString.fromNumber(options.maxUnavailable as number); | ||
} else if (typeof maxUnavailable === 'string') { | ||
maxUnavailable = IntOrString.fromString(options.maxUnavailable as string); | ||
} | ||
var minAvailable: IntOrString = IntOrString.fromString(''); // default value | ||
if (typeof minAvailable === 'number') { | ||
minAvailable = IntOrString.fromNumber(options.minAvailable as number); | ||
} else if (typeof minAvailable === 'string') { | ||
minAvailable = IntOrString.fromString(options.minAvailable as string); | ||
} | ||
|
||
new KubePodDisruptionBudget(this, 'PDB', { | ||
metadata: { | ||
labels: options.labels ?? {}, | ||
}, | ||
spec: { | ||
selector: { matchLabels: options.selector_label }, | ||
maxUnavailable: maxUnavailable, | ||
minAvailable: minAvailable, | ||
}, | ||
}); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.