Here are some installation procedures of Knative:

  • Serving Component Installation
    • The deployment of CRD
    • Deploying the Serving core
    • Install istio
    • Configure DNS
  • Eventing components installed
    • The deployment of CRD
    • Deploy the Eventing core
    • Install the default message channel
    • Install the default message broker
  • Command line KN compiler installation
  • Example demonstrates

Serving Component Installation

The deployment of CRD

Direct execution

Kubectl apply - filename https://github.com/knative/serving/releases/download/v0.19.0/serving-crds.yamlCopy the code

Deploying the Serving core

Direct execution

Kubectl apply - filename https://github.com/knative/serving/releases/download/v0.19.0/serving-core.yamlCopy the code

Install istio

Select ISTIO as the network routing component. Other options include Ambassador, Contour, Gloo, Kong, Kourier, and execute directly

Kubectl apply - filename https://github.com/knative/net-istio/releases/download/v0.19.0/release.yamlCopy the code

The installation of ISITO takes a little longer:

Configure DNS

Obtain the IP address of the ISITO gateway

kubectl --namespace istio-system get service istio-ingressgateway
Copy the code

Use magic DNS (xip. IO), production must be using real DNS. Here Knative provides a simple Kubernetes job, called the “default domain”, which configures Knative Serving to use xip.io as the default DNS suffix.

Kubectl apply - filename https://github.com/knative/serving/releases/download/v0.19.0/serving-default-domain.yamlCopy the code

As you can see, there are many new pods created after the installation,

Eventing components installed

The deployment of CRD

Direct execution

Kubectl apply - filename https://github.com/knative/eventing/releases/download/v0.19.0/eventing-crds.yamlCopy the code

The execution process is shown as follows:

Deploy the Eventing core

Direct execution

Kubectl apply - filename https://github.com/knative/eventing/releases/download/v0.19.0/eventing-core.yamlCopy the code

The execution process is shown as follows:

Install the default message channel

Select memory as the message channel component. Other options include Kafka, Google’s PubSub, and Nats, which execute directly

Kubectl apply - filename https://github.com/knative/eventing/releases/download/v0.19.0/in-memory-channel.yamlCopy the code

The installation process is shown as follows:

Install the default message broker

Select memory as the message Broker component. Other options include Kafka, which executes directly

Kubectl apply - filename https://github.com/knative/eventing/releases/download/v0.19.0/mt-channel-broker.yamlCopy the code

The installation process is shown as follows:

To customize which proxy channel implementation to use, update the following ConfigMap to specify which configurations to use for which namespaces:

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-br-defaults
  namespace: knative-eventing
data:
  default-br-config: | # This is the cluster-wide default broker channel. clusterDefault: brokerClass: MTChannelBasedBroker apiVersion: v1 kind: ConfigMap name: imc-channel namespace: knative-eventing # This allows you to specify different defaults per-namespace, # in this case the "some-namespace" namespace will use the Kafka # channel ConfigMap by default (only for example, you will need # to install kafka also to make use of this). namespaceDefaults: some-namespace: brokerClass: MTChannelBasedBroker apiVersion: v1 kind: ConfigMap name: kafka-channel namespace: knative-eventingCopy the code

The referenced imc-channel and kafka-channel sample ConfigMap looks like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: imc-channel
  namespace: knative-eventing
data:
  channelTemplateSpec: | apiVersion: messaging.knative.dev/v1 kind: InMemoryChannel---
apiVersion: v1
kind: ConfigMap
metadata:
  name: kafka-channel
  namespace: knative-eventing
data:
  channelTemplateSpec: | apiVersion: messaging.knative.dev/v1alpha1 kind: KafkaChannel spec: numPartitions: 3 replicationFactor: 1Copy the code

Eventing complete installation as shown below:

Command line KN compiler installation

Clone repository, execute the compile command

git clone https://github.com/knative/client.git
cd client/
hack/build.sh -f
Copy the code

After executing, you can see the binary of KN,

Example demonstrates

Using the official example of KN deployment, I have modified the repository of the image here,

# Create a Knative service with the Knative CLI kn
kn service create helloworld-go --image gcr.io/knative-samples/helloworld-go --env TARGET="Go Sample v1"
Copy the code

The installation process is shown as follows:After the installation is complete, view the installation result:Here I have changed the address of the sidecar mirror as shown below:

The POD will not be deployed immediately. It will need to be deployed after the first call, as follows:

# curl http://helloworld-go.default.34.83.80.117.xip.io
Hello World: Go Sample v1!
Copy the code

You can see the result below:

See the change in pod numbers:

Let’s start demonstrating eventing as the default broker:

kubectl create -f - <<EOF
apiVersion: eventing.knative.dev/v1
kind: broker
metadata:
 name: default
 namespace: event-example
EOF
Copy the code

Then create a consumer:

kubectl -n event-example apply -f - << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-display
spec:
  replicas: 1
  selector:
    matchLabels: &labels
      app: hello-display
  template:
    metadata:
      labels: *labels
    spec:
      containers:
        - name: event-display
          image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

---

kind: Service
apiVersion: v1
metadata:
  name: hello-display
spec:
  selector:
    app: hello-display
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
EOF
kubectl -n event-example apply -f - << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: goodbye-display
spec:
  replicas: 1
  selector:
    matchLabels: &labels
      app: goodbye-display
  template:
    metadata:
      labels: *labels
    spec:
      containers:
        - name: event-display
          # Source code: https://github.com/knative/eventing-contrib/tree/master/cmd/event_display
          image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

---

kind: Service
apiVersion: v1
metadata:
  name: goodbye-display
spec:
  selector:
    app: goodbye-display
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
EOF
Copy the code

After installation, the picture is as follows:

Then define the trigger:

kubectl -n event-example apply -f - << EOF
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: hello-display
spec:
  broker: default
  filter:
    attributes:
      type: greeting
  subscriber:
    ref:
     apiVersion: v1
     kind: Service
     name: hello-display
EOF

kubectl -n event-example apply -f - << EOF
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: goodbye-display
spec:
  broker: default
  filter:
    attributes:
      source: sendoff
  subscriber:
    ref:
     apiVersion: v1
     kind: Service
     name: goodbye-display
EOF
Copy the code

After installation, the picture is as follows:

Then call the test instance:

kubectl -n event-example apply -f - << EOF
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: curl
  name: curl
spec:
  containers:
    # This could be any image that we can SSH into and has curl.
  - image: radial/busyboxplus:curl
    imagePullPolicy: IfNotPresent
    name: curl
    resources: {}
    stdin: true
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    tty: true
EOF
Copy the code

The results are shown below:

So far, the process has been completed, and the architecture and source code of Knative components will be further studied.