34
loading...
This website collects cookies to deliver better user experience
brew install kind
choco install kind
GO111MODULE="on" go get sigs.k8s.io/[email protected]
kind create cluster
kind get clusters
kind export kubeconfig
kubectl cluster-info
kubectl create -f https://bit.ly/k4k8s
kubectl -n kong get service kong-proxy
kubectl -n kong port-forward --address localhost,0.0.0.0 svc/kong-proxy 8080:80
export PROXY_IP=localhost:8080
{"message":"no Route matched with those values"}
kubectl apply -f https://k8s.io/examples/application/guestbook/mongo-deployment.yaml
kubectl apply -f https://k8s.io/examples/application/guestbook/mongo-service.yaml
kubectl apply -f https://k8s.io/examples/application/guestbook/frontend-deployment.yaml
kubectl apply -f https://k8s.io/examples/application/guestbook/frontend-service.yaml
kubectl get pods -l app.kubernetes.io/name=guestbook -l app.kubernetes.io/component=frontend
kubectl port-forward svc/frontend 8000:80
echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: guestbook
annotations:
konghq.com/strip-path: "true"
kubernetes.io/ingress.class: kong
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend
port:
number: 80
' | kubectl apply -f -
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: rl-by-ip
config:
minute: 5
limit_by: ip
policy: local
plugin: rate-limiting
" | kubectl apply -f -
kongplugin.configuration.konghq.com/rl-by-ip created
kubectl patch svc frontend \
-p '{"metadata":{"annotations":{"konghq.com/plugins": "rl-by-ip\n"}}}'
kubectl patch ingress guestbook -p
'{"metadata":{"annotations":{"konghq.com/protocols":"https","konghq.com/https-redirect-status-code":"301"}}}'
kubectl -n kong port-forward --address localhost,0.0.0.0 svc/kong-proxy 8443:443
kubectl apply -f
https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml
kubectl get all -n cert-manager
kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" service -n kong kong-proxy
echo "apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
namespace: cert-manager
spec:
acme:
email: [email protected] #change this email
privateKeySecretRef:
name: letsencrypt-prod
server: https://acme-v02.api.letsencrypt.org/directory
solvers:
- http01:
ingress:
class: kong" | kubectl apply -f -
echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: guestbook-example-com
annotations:
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: kong
spec:
tls:
- secretName: guestbook-example-com
hosts:
- demo.example.com #change this domain/subdomain
rules:
- host: demo.example.com #change this domain/subdomain
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: guestbook
port:
number: 80
' | kubectl apply -f -
34