Defenseunicorns Pepr Versions Save

Type safe K8s middleware for humans

v0.31.1

1 week ago

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.31.0...v0.31.1

v0.31.0

2 weeks ago

Feats

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.30.2...v0.31.0

v0.30.2

3 weeks ago

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.30.1...v0.30.2

v0.30.1

3 weeks ago

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.30.0...v0.30.1

v0.30.0

4 weeks ago

Features

What's Changed

New Contributors

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.29.2...v0.30.0

v0.29.2

1 month ago

Usage

In order to look for Watch events from the Watch Controller:

kubectl logs -n pepr-system -l pepr.dev/controller=watcher -f | jq 'select(.msg != null and (.msg | test("^Watch event.+")))'

To get results:


{
  "level": 20,
  "time": 1713451863516,
  "pid": 19,
  "hostname": "pepr-6233c672-7fca-5603-8e90-771828dd30fa-watcher-558d5f5d45vkq",
  "msg": "Watch event resource_version received"
}
{
  "level": 20,
  "time": 1713451903555,
  "pid": 19,
  "hostname": "pepr-6233c672-7fca-5603-8e90-771828dd30fa-watcher-558d5f5d45vkq",
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "name": "a-12",
    "namespace": "pepr-demo",
    "uid": "990c7f3d-ac3e-4933-9f05-f63f88726457",
    "resourceVersion": "1739",
    "creationTimestamp": "2024-04-18T14:51:43Z",
    "managedFields": [
      {
        "manager": "kubectl-create",
        "operation": "Update",
        "apiVersion": "v1",
        "time": "2024-04-18T14:51:43Z",
        "fieldsType": "FieldsV1",
        "fieldsV1": {
          "f:data": {
            ".": {},
            "f:a": {}
          }
        }
      }
    ]
  },
  "data": {
    "a": "a"
  },
  "msg": "Watch event ADDED received"
}
{
  "level": 20,
  "time": 1713451908578,
  "pid": 19,
  "hostname": "pepr-6233c672-7fca-5603-8e90-771828dd30fa-watcher-558d5f5d45vkq",
  "msg": "Watch event resource_version received"
}

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.29.1...v0.29.2

v0.29.1

1 month ago

What's Changed

New Contributors

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.29.0...v0.29.1

v0.29.0

1 month ago

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

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.28.8...v0.29.0

v0.28.8

1 month ago

What's Changed

New Contributors

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.28.7...v0.28.8

v0.28.7

2 months ago

What's Changed

Full Changelog: https://github.com/defenseunicorns/pepr/compare/v0.28.6...v0.28.7