8000 GitHub - cmwylie19/pepr-informer
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cmwylie19/pepr-informer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
< 8000 svg aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom">
 
 

Repository files navigation

Pepr Informer

A simple gRPC server that watches for Kubernetes resources and streams events to clients. It can be run in or out of cluster (for pepr dev).

Starts the pepr-informer

Usage:
  pepr-informer [flags]

Flags:
  -h, --help               help for pepr-informer
      --in-cluster         Use in-cluster configuration (default true)
  -l, --log-level string   Log level (debug, info, error) (default "info")

Prereqs

Add the repo

helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm install nats nats/nats --set namespaceOverride=pepr-system

Local Development

./nats-server&
go run main.go --server-address=":8080" --nats-url="nats://localhost:4222" --in-cluster=false
NATS_URL="nats://localhost:4222" npx pepr dev --confirm 
curl -X POST http://localhost:8080/watch -H "Content-Type: application/json" -d '{
  "group": "",
  "version": "v1",
  "resource": "pods",
  "namespace": "default"
}'

curl -X POST http://localhost:8080/watch -H "Content-Type: application/json" -d '{
  "group": "",
  "version": "v1",
  "resource": "pods",
  "namespace": ""
}'

curl -X POST http://localhost:8080/watch -H "Content-Type: application/json" -d '{
  "group": "apps",
  "version": "v1",
  "resource": "deployments",
  "namespace": "default"
}'

nats sub "k8s.apps.v1.deployments.default"
nats sub "k8s.v1.pods.default"
nats sub "k8s.v1.pods"

subscribe through nats cli

nats context add localhost --description "Localhost"
nats ctx select localhost
nats sub "k8s.ADD"

Usage

Bring up a dev cluster with application deployed

make deploy-dev

Get Events

make curl-dev

Test

unit

make unit test

e2e

make e2e test
        - name: informer
          image: pepr-informer:dev
          command: ["./pepr-informer", "--server-address=:8080", "--nats-url=nats://nats-headless:4222"]
          resources:
            requests:
              memory: 128Mi
              cpu: 100m
            limits:
              memory: 128Mi
              cpu: 200m
import {
  Capability,
  K8s,
  a,
} from "pepr";

/**
 *  The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.
 *  To test this capability you run `pepr dev`and then run the following command:
 *  `kubectl apply -f capabilities/hello-pepr.samples.yaml`
 */
export const HelloPepr = new Capability({
  name: "hello-pepr",
  description: "A simple example capability to show how things work."
});

// Use the 'When' function to create a new action, use 'Store' to persist data
const { When } = HelloPepr;
const deletePod = async (name: string) => {
  await K8s(a.Pod).InNamespace("pepr-demo").Delete(name);
};

When(a.Pod)
  .IsCreatedOrUpdated()
  .InNamespace("pepr-demo")
  .Reconcile(async instance => {
    await deletePod(instance.metadata.name);
  });

Demo

Set up

k3d cluster delete k3s-default;
docker rmi -f pepr-informer:dev;
docker rmi -f pepr:informer; 
k3d cluster create;
make build-dev-image;
# in pepr npm run build:image
k3d image import pepr-informer:dev -c k3s-default
k3d image import pepr:dev -c k3s-default
k3d image import nginx -c k3s-default
k create ns pepr-system;
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm install nats nats/nats --set namespaceOverride=pepr-system
k3d cluster delete k3s-default;
k3d cluster create;
# make build-dev-image;
# in pepr npm run build:image
k3d image import pepr-informer:dev -c k3s-default
k3d image import pepr:informer -c k3s-default
k3d image import nginx -c k3s-default
k create ns pepr-system;
k create ns pepr-demo 
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm install nats nats/nats --set namespaceOverride=pepr-system
sleep 4
k wait --for=condition=ready -n pepr-system po -l app.kubernetes.io/component=nats
kubectl apply -f dist
k3d cluster delete k3s-default;
k3d cluster create;
k3d image import pepr:dev -c k3s-default
k3d image import nginx -c k3s-default
k create ns pepr-demo 
k wait --for=condition=ready -n pepr-system po -l pepr.dev/controller=server
k apply -f dist
for x in $(seq 2000); do kubectl run a$x --image=nginx -n pepr-demo --image-pull-policy=IfNotPresent; done

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0