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

fix: bug issue 47 disabling livenessProbes creates corrupted manifests #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 1 addition & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This chart provides a library to bootstrap a Plone deployment on a Kubernetes cluster using the [CDK8S](https://cdk8s.io) framework.

It provides
- Backend (for API with `plone.volto` or as Classic-UI)
- Backend (as API with `plone.volto` or as Classic-UI)
- Frontend (Plone-Volto, a ReactJS based user interface)
- Varnish using kube-httpcache. It includes a way to invalidate varnish cluster (optional)

Expand Down Expand Up @@ -39,8 +39,6 @@ cdk8s init python-app
Python package name is [cdk8s-plone](https://pypi.org/project/cdk8s-plone/).




## Usage

With `cdk8s-cli` installed, create a new project:
Expand Down Expand Up @@ -84,35 +82,3 @@ Then run the following command to run the test:
```bash
npx projen test
```

### Feature Wishlist:

Each step need to be implemented with tests!

- [x] Support Variants for ClassicUI or Volto
- [ ] Start Backend
- [x] deployment
- [x] service
- [x] pdb
- [ ] init container running `plone-site-create`
- [x] lifecycle checks (readiness, liveness)
- [x] generic way to inject sidecars
- [ ] metrics sidecar
- [ ] Start Frontend
- [x] deployment
- [x] service
- [x] pdb
- [x] lifecycle checks (readiness, liveness)
- [x] generic way to inject sidecars
- [ ] metrics sidecar
- [x] Start Varnish (using `kube-httpcache`) optional in separate chart
- [x] provide a default VCL for Volto with routing to backend and frontend
- [ ] provide a default VCL for ClassicUI
- [ ] Configure Ingress, optional in separate chart
- [ ] Traefik
- [ ] Konq

- [ ] Release packages for other Languages
- [x] Python
- [ ] Golang
- [ ] Java
4 changes: 2 additions & 2 deletions src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ export interface PloneDeploymentOptions {
* Liveness Probe for the pod.
* @default - generated
*/
readonly livenessProbe?: k8s.Probe;
livenessProbe?: k8s.Probe;

/**
* Readiness Probe for the pod.
* @default - generated
*/
readonly readinessProbe?: k8s.Probe;
readinessProbe?: k8s.Probe;

}

Expand Down
118 changes: 58 additions & 60 deletions src/plone.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Names } from 'cdk8s';
import * as kplus from 'cdk8s-plus-24';
import { Construct } from 'constructs';
import { PloneDeployment } from './deployment';
import { Probe, IntOrString } from './imports/k8s';
import { PloneDeployment, PloneDeploymentOptions } from './deployment';
import { IntOrString } from './imports/k8s';
import * as k8s from './imports/k8s';
import { PloneService } from './service';

Expand Down Expand Up @@ -80,14 +80,34 @@ export class Plone extends Construct {
};
const backendPort = 8080;

// Options
var backendOptions: PloneDeploymentOptions = {
labels: backendLabels,
image: {
image: backend.image ?? 'plone/plone-backend:latest',
imagePullSecrets: options.imagePullSecrets ?? [],
imagePullPolicy: backend.imagePullPolicy ?? 'IfNotPresent',
},
replicas: backend.replicas,
limitCpu: backend.limitCpu ?? '500m',
limitMemory: backend.limitMemory ?? '512Mi',
requestCpu: backend.requestCpu ?? '200m',
requestMemory: backend.requestMemory ?? '256Mi',
pdb: {
maxUnavailable: backend.maxUnavailable ?? undefined,
minAvailable: backend.minAvailable ?? undefined,
},
port: backendPort,
environment: backend.environment,
};

// Probing
const backendActionHttpGet: k8s.HttpGetAction = {
path: '/',
port: IntOrString.fromNumber(backendPort),
};
var backendLivenessProbe: Probe | undefined = undefined;
if (backend.livenessEnabled ?? false) {
backendLivenessProbe = {
backendOptions.livenessProbe = {
httpGet: backendActionHttpGet,
initialDelaySeconds: backend.livenessInitialDelaySeconds ?? 30,
timeoutSeconds: backend.livenessIimeoutSeconds ?? 5,
Expand All @@ -96,9 +116,8 @@ export class Plone extends Construct {
failureThreshold: backend.livenessFailureThreshold ?? 3,
};
}
var backendReadinessProbe: Probe | undefined = undefined;
if (backend.readinessEnabled ?? true) {
backendReadinessProbe = {
backendOptions.readinessProbe = {
httpGet: backendActionHttpGet,
initialDelaySeconds: backend.readinessInitialDelaySeconds ?? 10,
timeoutSeconds: backend.readinessIimeoutSeconds ?? 15,
Expand All @@ -108,27 +127,7 @@ export class Plone extends Construct {
};
}
// Deployment
const backendDeployment = new PloneDeployment(this, 'backend', {
labels: backendLabels,
image: {
image: backend.image ?? 'plone/plone-backend:latest',
imagePullSecrets: options.imagePullSecrets ?? [],
imagePullPolicy: backend.imagePullPolicy ?? 'IfNotPresent',
},
replicas: backend.replicas,
limitCpu: backend.limitCpu ?? '500m',
limitMemory: backend.limitMemory ?? '512Mi',
requestCpu: backend.requestCpu ?? '200m',
requestMemory: backend.requestMemory ?? '256Mi',
pdb: {
maxUnavailable: backend.maxUnavailable ?? undefined,
minAvailable: backend.minAvailable ?? undefined,
},
port: backendPort,
environment: backend.environment,
livenessProbe: backendLivenessProbe,
readinessProbe: backendReadinessProbe,
});
var backendDeployment = new PloneDeployment(this, 'backend', backendOptions);

// Service
const backendService = new PloneService(backendDeployment, 'service', {
Expand All @@ -152,43 +151,15 @@ export class Plone extends Construct {
'app.kubernetes.io/version': options.version ?? 'undefined',
};

// Probing
const frontendActionHttpGet: k8s.HttpGetAction = {
path: '/',
port: IntOrString.fromNumber(frontendPort),
};
var frontendLivenessProbe: Probe | undefined = undefined;
if (frontend.livenessEnabled ?? false) {
frontendLivenessProbe = {
httpGet: frontendActionHttpGet,
initialDelaySeconds: frontend.livenessInitialDelaySeconds ?? 30,
timeoutSeconds: frontend.livenessIimeoutSeconds ?? 5,
periodSeconds: frontend.livenessPeriodSeconds ?? 10,
successThreshold: frontend.livenessSuccessThreshold ?? 1,
failureThreshold: frontend.livenessFailureThreshold ?? 3,
};
}
var frontendReadinessProbe: Probe | undefined = undefined;
if (frontend.readinessEnabled ?? true) {
frontendReadinessProbe = {
httpGet: frontendActionHttpGet,
initialDelaySeconds: frontend.readinessInitialDelaySeconds ?? 10,
timeoutSeconds: frontend.readinessIimeoutSeconds ?? 15,
periodSeconds: frontend.readinessPeriodSeconds ?? 10,
successThreshold: frontend.readinessSuccessThreshold ?? 1,
failureThreshold: frontend.readinessFailureThreshold ?? 3,
};
}

// Environment for RAZZLE
var frontendEnvironment = frontend.environment ?? new kplus.Env([], {});
if (frontendEnvironment.variables.RAZZLE_INTERNAL_API_PATH === undefined) {
// connect with backend service
frontendEnvironment?.addVariable('RAZZLE_INTERNAL_API_PATH', kplus.EnvValue.fromValue(`http://${backendService.name}:${backendPort}/${this.siteId}`));
}

// Deployment
const frontendDeployment = new PloneDeployment(this, 'frontend', {
// Options
var frontendOptions: PloneDeploymentOptions = {
labels: frontendLabels,
image: {
image: frontend.image ?? 'plone/plone-frontend:latest',
Expand All @@ -207,9 +178,36 @@ export class Plone extends Construct {
},
port: frontendPort,
environment: frontendEnvironment,
livenessProbe: frontendLivenessProbe,
readinessProbe: frontendReadinessProbe,
});
};

// Probing
const frontendActionHttpGet: k8s.HttpGetAction = {
path: '/',
port: IntOrString.fromNumber(frontendPort),
};
if (frontend.livenessEnabled ?? false) {
frontendOptions.livenessProbe = {
httpGet: frontendActionHttpGet,
initialDelaySeconds: frontend.livenessInitialDelaySeconds ?? 30,
timeoutSeconds: frontend.livenessIimeoutSeconds ?? 5,
periodSeconds: frontend.livenessPeriodSeconds ?? 10,
successThreshold: frontend.livenessSuccessThreshold ?? 1,
failureThreshold: frontend.livenessFailureThreshold ?? 3,
};
}
if (frontend.readinessEnabled ?? true) {
frontendOptions.readinessProbe = {
httpGet: frontendActionHttpGet,
initialDelaySeconds: frontend.readinessInitialDelaySeconds ?? 10,
timeoutSeconds: frontend.readinessIimeoutSeconds ?? 15,
periodSeconds: frontend.readinessPeriodSeconds ?? 10,
successThreshold: frontend.readinessSuccessThreshold ?? 1,
failureThreshold: frontend.readinessFailureThreshold ?? 3,
};
}

// Deployment
const frontendDeployment = new PloneDeployment(this, 'frontend', frontendOptions);

// Service
const frontendService = new PloneService(frontendDeployment, 'service', {
Expand Down
Loading