v0.29.0
features
- chore: create helper functions for pepr by @schaeferka in #688
getOwnerRefFrom - get fields needed to create an owner ref
// Create a deployment that is "owned" by the WebApp instance π
function deployment(instance: WebApp) {
const { name, namespace } = instance.metadata!;
const { replicas } = instance.spec!;
return {
apiVersion: "apps/v1",
kind: "Deployment",
metadata: {
ownerReferences: getOwnerRefFrom(instance), // π Instance owns deploymeny
name,
namespace,
labels: {
"pepr.dev/operator": name,
},
},
containers - Get all of the containers from a pod
When(a.Pod)
.IsCreatedOrUpdated()
.Validate(po => {
const podContainers = containers(po); // containers, initContainer, ephemeralContainers π
for (const container of podContainers) {
if (
container.securityContext?.allowPrivilegeEscalation ||
container.securityContext?.privileged
) {
return po.Deny("Privilege escalation is not allowed");
}
}
return po.Approve();
});
writeEvent - write an event
async function updateStatus(instance: WebApp, status: Status) {
await writeEvent(instance, {phase: status}, "Normal", "CreatedOrUpdate", instance.metadata.name, instance.metadata.name);
await K8s(WebApp).PatchStatus({
metadata: {
name: instance.metadata!.name,
namespace: instance.metadata!.namespace,
},
status,
});
}
kubectl describe wa webapp-light-en -n webapps
# output
Name: webapp-light-en
Namespace: webapps
API Version: pepr.io/v1alpha1
Kind: WebApp
Metadata: ...
Spec:
Language: en
Replicas: 1
Theme: light
Status:
Observed Generation: 1
Phase: Ready
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal InstanceCreatedOrUpdated 36s webapp-light-en Pending π
Normal InstanceCreatedOrUpdated 36s webapp-light-en Ready π
Take a look at the sdk functions.
Good job @schaeferka π
What's Changed
- chore: onschedule runs always in dev mode by @cmwylie19 in #725
- chore: update docs on the operator by @cmwylie19 in #726
- chore: bump chainguard/node-lts from
cc860c4
to8c5f0eb
by @dependabot in #721 - chore: bump @types/node from 18.19.29 to 18.19.30 in the development-dependencies group by @dependabot in #720
Full Changelog: v0.28.8...v0.29.0