Install istio from resource files:
#Install istio components
kubectl apply -f https://storage.googleapis.com/knative-releases/serving/latest/istio.yaml
#Check and wait for istio pod readiness
kubectl get pods -w -n istio-system
#Label default namespace for istio injection
kubectl label ns default istio-injection=enabled
Note: Apply command needs to be executed twice due to crs being processed before crds
Deployment order: serving, build and eventing.
#Install knative serving
kubectl apply -f https://storage.googleapis.com/knative-releases/serving/latest/serving.yaml --validate=false
#Check and wait for knative serving pods readiness
kubectl get pods -w -n knative-serving
Note: validation error at the time of this writing (use --validate=false
until fixed)
#Install knative build
kubectl apply -f https://storage.googleapis.com/knative-releases/build/latest/build.yaml --validate=false
#Check and wait for knative build pods readiness
kubectl get pods -w -n knative-build
Note: validation error at the time of this writing (use --validate=false
until fixed)
This step is optional.
No wait time, those are just custom resources:
kubectl apply -f https://raw.githubusercontent.com/knative/build-templates/master/kaniko/kaniko.yaml
kubectl apply -f https://raw.githubusercontent.com/knative/build-templates/master/buildpack/buildpack.yaml
Verify build template installation resources:
$ kubectl get knative
NAME AGE
buildtemplates/buildpack 14s
buildtemplates/kaniko 33s
#Install knative eventing
kubectl apply -f https://storage.googleapis.com/knative-releases/eventing/latest/eventing.yaml --validate=false
#Wait and for knative eventing pods readiness
kubectl get pods -w -n knative-eventing
Note: validation error at the time of this writing (use --validate=false
until fixed)
Retrieve your knative host address:
export KNATIVE_INGRESS_IP=$(kubectl get node -o jsonpath='{.items[0].status.addresses[0].address}')
export KNATIVE_INGRESS_PORT=$(kubectl get svc/istio-ingressgateway -n istio-system -o jsonpath='{.spec.ports[?(@.port==80)].nodePort}')
export KNATIVE_INGRESS=$KNATIVE_INGRESS_IP:$KNATIVE_INGRESS_PORT
echo $KNATIVE_INGRESS
Save the following knative service definition as service.yaml
:
apiVersion: serving.knative.dev/v1alpha1 # Current version of Knative
kind: Service
metadata:
name: helloworld-go # The name of the app
namespace: default # The namespace the app will use
spec:
runLatest:
configuration:
revisionTemplate:
spec:
container:
image: gcr.io/knative-samples/helloworld-go # The URL to the image of the app
env:
- name: TARGET # The environment variable printed out by the sample app
value: "Go Sample v1"
Create your service by running:
#Create the service
kubectl apply -f service.yaml
#Check your knative service
kubectl get ksvc helloworld-go
Test the helloworld app using curl:
#example.com is used as the default domain in case of no load balancer/external ip which is expected in a local vm instance.
# url format is: $REVISION_NAME.$SERVICE_NAME.$NAMESPACE.$DOMAIN
$ curl -H 'Host: helloworld-go.default.example.com' http://$KNATIVE_INGRESS
Hello Go Sample v1!