Skip to content

v0.29.0

Compare
Choose a tag to compare
@cmwylie19 cmwylie19 released this 08 Apr 15:44
· 295 commits to main since this release
a0b27bb

features

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 to 8c5f0eb 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