#!/bin/sh set -xe if [ -f "${K3D_ENV}" ]; then source "${K3D_ENV}" fi if [ "x${DOMAIN}" == "x" ]; then echo "[-] ERROR: DOMAIN (aka example.com) not set" >&2 exit 1 fi if [ "x${EMAIL}" == "x" ]; then echo "[-] ERROR: EMAIL (Your email for Let's Encrypt ACME) not set" >&2 exit 1 fi if [ "x${DO_PA_TOKEN}" == "x" ]; then echo "[-] ERROR: DO_PA_TOKEN (DigitalOcean Personal Access Token) not set" >&2 exit 1 fi k3d create --auto-restart --workers 3 --publish 80:80 --publish 443:433 --image docker.io/rancher/k3s:v0.7.0-rc6 kube_up() { k3d get-kubeconfig --name='k3s-default' 2>&1 } set +e KUBE_UP="$(kube_up | grep -E 'does not exist|copy kubeconfig')" while [ "x${KUBE_UP}" != "x" ]; do sleep 0.25s KUBE_UP="$(kube_up | grep -E 'does not exist|copy kubeconfig')" done set -e export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')" kubectl cluster-info kubectl create namespace helm-world kubectl create namespace tiller-world kubectl create serviceaccount tiller --namespace tiller-world kubectl create -f - << EOF apiVersion: v1 kind: ServiceAccount metadata: name: helm namespace: helm-world --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: tiller-user namespace: tiller-world rules: - apiGroups: - "" resources: - pods/portforward verbs: - create - apiGroups: - "" resources: - pods verbs: - list --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: tiller-user-binding namespace: tiller-world roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: tiller-user subjects: - kind: ServiceAccount name: helm namespace: helm-world EOF terraform init rm -f *.pem terraform apply -auto-approve # Installing Helm - Helm init helm init \ --override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' \ --tiller-tls \ --tiller-tls-verify \ --tls-ca-cert ca.cert.pem \ --tiller-tls-cert ./tiller.cert.pem \ --tiller-tls-key ./tiller.key.pem \ --tiller-namespace=tiller-world \ --service-account=tiller-user \ # Installing Istio for i in istio-?.?.?/install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl apply -f $i; done cat < ./istio.yaml kubectl apply -f istio.yaml helm template --namespace=istio-system \ --set gateways.custom-gateway.autoscaleMin=1 \ --set gateways.custom-gateway.autoscaleMax=1 \ --set gateways.custom-gateway.cpu.targetAverageUtilization=60 \ --set gateways.custom-gateway.labels.app='cluster-local-gateway' \ --set gateways.custom-gateway.labels.istio='cluster-local-gateway' \ --set gateways.custom-gateway.type='NodePort' \ --set gateways.istio-ingressgateway.enabled=false \ --set gateways.istio-egressgateway.enabled=false \ --set gateways.istio-ilbgateway.enabled=false \ istio-?.?.?/install/kubernetes/helm/istio \ -f istio-?.?.?/install/kubernetes/helm/istio/example-values/values-istio-gateways.yaml \ | sed -e "s/custom-gateway/cluster-local-gateway/g" -e "s/customgateway/clusterlocalgateway/g" \ > ./istio-local-gateway.yaml kubectl apply -f istio-local-gateway.yaml ISTIO_UP="$(kubectl get pods --namespace istio-system 2>&1)" while [ "x${ISTIO_UP}" == "xNo resources found." ]; do sleep 0.25s ISTIO_UP="$(kubectl get pods --namespace istio-system 2>&1)" done kubectl get pods --namespace istio-system set +e ISTIO_UP="$(kubectl get pods --namespace istio-system | grep -viE 'status|running|complete')" while [ "x${ISTIO_UP}" != "x" ]; do sleep 0.25s ISTIO_UP="$(kubectl get pods --namespace istio-system | grep -viE 'status|running|complete')" done kubectl get pods --namespace istio-system kubectl apply \ --selector knative.dev/crd-install=true \ --filename serving.yaml \ --filename build.yaml \ --filename release.yaml \ --filename monitoring.yaml kubectl apply \ --filename serving.yaml \ --selector networking.knative.dev/certificate-provider=cert-manager \ --filename build.yaml \ --filename release.yaml \ --filename monitoring.yaml sleep 2 kubectl get pods --namespace knative-serving kubectl get pods --namespace knative-build kubectl get pods --namespace knative-eventing kubectl get pods --namespace knative-monitoring kubectl get deploy -n knative-serving --label-columns=serving.knative.dev/release cat <