Skip to content

Instantly share code, notes, and snippets.

@PierreAndreis
Forked from craftyc0der/README.md
Created November 11, 2022 03:10
Show Gist options
  • Save PierreAndreis/14989c48e5ae505e9cd7cc025412db8d to your computer and use it in GitHub Desktop.
Save PierreAndreis/14989c48e5ae505e9cd7cc025412db8d to your computer and use it in GitHub Desktop.
Minikube/Ambassador/Agones

Minikube - Agones

Install Ambassador

helm repo add datawire https://app.getambassador.io
helm repo update

helm install -n emissary --create-namespace \
    emissary-ingress --devel \
    datawire/emissary-ingress && \
kubectl rollout status  -n emissary deployment/emissary-ingress -w

Install Agones

helm repo add agones https://agones.dev/chart/stable
helm repo update
helm install agones --namespace agones-system --create-namespace agones/agones

Install Docker Registry Container

This is necessary if you want to build a container locally and deploy it.

To tag the container localhost:5000/$name/$tag and docker push it.

More details about this here.

kubectl create -f kube-registry.yaml
minikube ssh && curl localhost:5000

Setup Ports

kubectl port-forward --namespace kube-system $(kubectl get po -n kube-system | grep kube-registry-v0 | \awk '{print $1;}') 5000:5000
minikube tunnel
kubectl port-forward -n emissary emissary-ingress-7b9ddb765f-6rmkm 9991:80

Your emissary pod name will be different.

Add Test Deployment

kubectl create -f am-test.yaml

You can now reach Ambassador's edge node via http://127.0.0.1:9991/backend/ It will return something like:

{
    "server": "negative-pomegranate-1kz13haz",
    "quote": "The light at the end of the tunnel is interdependent on the relatedness of motivation, subcultures, and management.",
    "time": "2021-08-15T21:12:09.486270546Z"
}
---
apiVersion: x.getambassador.io/v3alpha1
kind: AmbassadorListener
metadata:
name: http-listener
namespace: emissary
spec:
port: 80
protocol: HTTP
securityModel: INSECURE
hostBinding:
namespace:
from: ALL
---
apiVersion: x.getambassador.io/v3alpha1
kind: AmbassadorHost
metadata:
name: foo-host
namespace: emissary
spec:
hostname: "127.0.0.1:9991"
requestPolicy:
insecure:
action: Route
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: quote
spec:
replicas: 1
selector:
matchLabels:
app: quote
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: quote
spec:
containers:
- name: backend
image: docker.io/datawire/quote:0.5.0
ports:
- name: http
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: quote
spec:
ports:
- name: http
port: 80
targetPort: 8080
selector:
app: quote
---
apiVersion: x.getambassador.io/v3alpha1
kind: AmbassadorMapping
metadata:
name: quote-backend
labels:
exampleName: basic-https
spec:
prefix: /backend/
service: quote
hostname: '127.0.0.1:9991'
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
selector:
k8s-app: kube-registry
version: v0
template:
metadata:
labels:
k8s-app: kube-registry
version: v0
spec:
containers:
- name: registry
image: registry:2.5.1
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 100m
memory: 100Mi
env:
- name: REGISTRY_HTTP_ADDR
value: :5000
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: /var/lib/registry
volumeMounts:
- name: image-store
mountPath: /var/lib/registry
ports:
- containerPort: 5000
name: registry
protocol: TCP
volumes:
- name: image-store
hostPath:
path: /data/registry/
---
apiVersion: v1
kind: Service
metadata:
name: kube-registry
namespace: kube-system
labels:
k8s-app: kube-registry
spec:
selector:
k8s-app: kube-registry
ports:
- name: registry
port: 5000
protocol: TCP
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kube-registry-proxy
namespace: kube-system
labels:
k8s-app: kube-registry
kubernetes.io/cluster-service: "true"
version: v0.4
spec:
selector:
matchLabels:
k8s-app: kube-registry
version: v0.4
template:
metadata:
labels:
k8s-app: kube-registry
version: v0.4
spec:
containers:
- name: kube-registry-proxy
image: gcr.io/google_containers/kube-registry-proxy:0.4
resources:
limits:
cpu: 100m
memory: 50Mi
env:
- name: REGISTRY_HOST
value: kube-registry.kube-system.svc.cluster.local
- name: REGISTRY_PORT
value: "5000"
ports:
- name: registry
containerPort: 80
hostPort: 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment