Based on the development and application Knative


title: (c) to develop applications based on Knative

table of Contents

  • Installation Istio
  • Installation Knative
  • Fun helloworld-go
  • WordPress combat

Creating a cluster Kubernetes

  • Ensure Kubernetes created when a cluster has been selected to enable logging services
  • Ensure Kubernetes clusters and OSS in a region
  • Kubernetes cluster created when the need to open access to the public network kube-apiserver
  • Advance to help users configure kubeconfig command line

Installation Istio

Note the following when installing Istio:

  • To install the default gateway
  • Log service and Xtrace to be opened in advance, Istio ZipKin v1 need to use the monitoring data to report Xtrace

Services in container cluster management page can be deployed directly on the target cluster Istio

Installation Knative

Choose a good target cluster using a function key can be installed directly deployment, installation documentation

Fun helloworld-go

  • Configure log collection policy
  • Deployment Helloworld
  • Monitoring Alarms
  • Call chain
  • Pressure test data show

Log Management

  • Log service console: https://sls.console.aliyun.com
  • This example shows exemplary capture container to the standard output setting step can be detailed with reference to the log service documentation
  • Find the corresponding log service based on Kubernetes cluster ID Project
  • Create a new Logstore

Data import mode setting

Select Docker standard output

  • Configuration container standard output log acquisition strategy
{
  "inputs": [
    {
      "detail": {
        "IncludeEnv": {
          "K_SERVICE": "helloworld-go"
        },
        "IncludeLabel": {},
        "ExcludeLabel": {}
      },
      "type": "service_docker_stdout"
    }
  ],
  "processors": [
    {
      "detail": {
        "KeepSource": false,
        "NoMatchError": true,
        "Keys": [
          "time",
          "level",
          "msg"
        ],
        "NoKeyError": true,
        "Regex": "(\\d+-\\d+-\\d+ \\d+:\\d+:\\d+)\\s+(\\w+)\\s+(*)",
        "SourceKey": "content"
      },
      "type": "processor_regex"
    }
  ]
}

Key respectively corresponding time, level and set the data type msg

Deployment Helloworld

  • Ready kubeconfig

Container services to console page, open cluster details page. Save KubeConfig copy the contents to your local ~ / .kube / config file

Multi-access times generate some helloworld-go access log

./sample/run-test.sh

Generate some access log after clicking the query, you can view the log

Log service console: https://sls.console.aliyun.com

Log service has a wealth of query conditions, such as query logs ERROR

Monitoring Alarms

Query to search under use, this statement uses a SELECT, it may be a higher level of operation.

level:ERROR | SELECT  COUNT(*) as total

ERROR log search, select a time span of minutes.

Click Save as alert

Variable trigger condition is left of the table column names

Meanings are as follows provided that the number of one minute retrieves ERROR logging alarm if greater than or equal to 4.

Alarm notification may be provided a variety of ways, and the alarm system variable body may also be used. Get the context alarms.

Open the mail can see the warning notice

Call chain

Select the appropriate Region, click Apply to see a list of apps list

Call chain query page

Pressure test data show

Download the source files: https://kstarter.oss-cn-beijing.aliyuncs.com/knload-result.html , directly open the browser to view

The number of concurrent pressure measured jitter increased sharply resulting in service response times, but as the number of automatic expansion Pod RT quickly returned to the normal level.

  • Pressure measuring tool knload
  • Analog end server: http-server

WordPress

  • Deploy WordPress
  • Modify the theme and plugin installation
  • OSS add a picture watermark
  • Live interactive pressure measurement

Deploy WordPress

  • engineering

  • Deploy WordPress

    ## ENV 换成具体的值
              env:
              - name: WORDPRESS_DB_HOST
                value: {db_host:3306}
              - name: WORDPRESS_DB_NAME
                value: {db_name}
              - name: WORDPRESS_DB_USER
                value: {db_user}
              - name: WORDPRESS_DB_PASSWORD
                value: {db_password}
                
    ## 部署 WordPress  # kubectl apply -f /Users/qiulin.nql/works/github/knative-sample/secret/wordpress-service.yaml 
    kubectl apply -f sample/service.yaml
  • Add Egress

    kubectl apply -f sample/egress.yaml 
  • Visit the WordPress service

    ./hack/run-wp-test.sh
  • host bind && browser access
  • Log Collection

    {
      "inputs": [
        {
          "detail": {
            "IncludeEnv": {
              "K_SERVICE": "wordpress"
            },
            "IncludeLabel": {},
            "ExcludeLabel": {}
          },
          "type": "service_docker_stdout"
        }
      ],
      "processors": [
        {
          "detail": {
            "KeepSource": false,
            "NoMatchError": true,
            "Keys": [
              "ip",
              "time",
              "req",
              "code"
            ],
            "NoKeyError": true,
            "Regex": "(\\d+.\\d+.\\d+.\\d+)\\s+-\\s+(\\d+/\\w+/\\d+:\\d+:\\d+:\\d+\\s\\+\\d+)\\s\"(.*)\"\\s(\\d+)",
            "SourceKey": "content"
          },
          "type": "processor_regex"
        }
      ]
    }

Multiple concurrent tests

hey -z 30s -c 50 "http://wordpress.default.example.com/" && kubectl get pods

Modify the theme and plugin installation

  • plugins

Guess you like

Origin yq.aliyun.com/articles/705455