0%

Kube Cluster Deployment Tools

1. Kubespray

Kubespray provides a set of Ansible roles for Kubernetes deployment and configuration. Kubespray can use AWS, GCE, Azure, OpenStack or a bare metal Infrastructure as a Service (IaaS) platform. Kubespray is an open-source project with an open development model. The tool is a good choice for people who already know Ansible as there’s no need to use another tool for provisioning and orchestration. Kubespray uses kubeadm under the hood.

Link: https://github.com/kubernetes-incubator/kubespray

Read more »

Logging

nginx provides two kinds of logs, ‘error’ log and debug log, you can use several APIs(macro) to log info to console or file, let’s explain how to use these APIs in detail.

support formats

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* src/core/ngx_string.c
* supported formats:
* %[0][width][x][X]O off_t
* %[0][width]T time_t
* %[0][width][u][x|X]z ssize_t/size_t
* %[0][width][u][x|X]d int/u_int
* %[0][width][u][x|X]l long
* %[0][width|m][u][x|X]i ngx_int_t/ngx_uint_t
* %[0][width][u][x|X]D int32_t/uint32_t
* %[0][width][u][x|X]L int64_t/uint64_t
* %[0][width|m][u][x|X]A ngx_atomic_int_t/ngx_atomic_uint_t
* %[0][width][.width]f double, max valid number fits to %18.15f
* %P ngx_pid_t
* %M ngx_msec_t
* %r rlim_t
* %p void *
* %V ngx_str_t *
* %v ngx_variable_value_t *
* %s null-terminated string
* %*s length and string
* %Z '\0'
* %N '\n'
* %c char
* %% %
*
* reserved:
* %t ptrdiff_t
* %S null-terminated wchar string
* %C wchar
*/
Read more »

Overview

nginx provides flexible way when processing header and body to meet different network env to achieve better performance, say nginx can send the request immediately after get the whole request headers, or send the request to upstream after get the entire body, when cache request body, we can cache it in memory if memory is large enough or cache it to a file.
Also we can cache the response body to a file or send it immediately to client, all are configurable!!!

Read more »

nginx

nginx can be used as light web server(serve request directly), reverse proxy(http) and proxy server(stream) for Pop3 and IMAP.

Read more »

Overview

nginx supports two kinds of log, one is error log, the other is access log, error log can happen at any time when process request, but access log only happens when a request is finalized, once a time.

Read more »

Overview

nginx provides flexible way to manipulate headers, you can do this by directive or by lua, here we only say directive, headers can be request header or response header, that means nginx gives you the way to manipulate request header before sending to upstream and response header before sending to client.
nginx supports

  • add a header
  • update existing header
  • delete a header

request header related directive before sending to upstream

  • proxy_set_header

response header related directives before sending to client

  • add_header
  • proxy_ignore_headers
  • proxy_hide_header
  • proxy_pass_header
Read more »

Overview

Http Keep alive(multiplexing) means after a TCP connection serves a request, it’s not closed by server, so that subsequent request can reuse the same connection to avoid create new. hence can improve http performance.
enable it from client side(make sure sever does not disable it)

  • Http 1.0: send request(explicit enable) Connection: keep-alive
  • Http 1.1 default is keep-alive(explicit disable Connection: close)

Note: even connection is keep-alive, it's not kept for ever if it's idle(most server has a timeout for idle connection).

Read more »

Overview

nginx provides several phases for developer, developer can register its own handler to some phases, do its own work without breaking nginx source code, it’s flexible, here are phases with order(runs from top to bottom).

  • NGX_HTTP_SERVER_REWRITE_PHASE
  • NGX_HTTP_FIND_CONFIG_PHASE
  • NGX_HTTP_REWRITE_PHASE
  • NGX_HTTP_POST_REWRITE_PHASE
  • NGX_HTTP_PREACCESS_PHASE
  • NGX_HTTP_ACCESS_PHASE
  • NGX_HTTP_POST_ACCESS_PHASE
  • NGX_HTTP_PRECONTENT_PHASE
  • NGX_HTTP_CONTENT_PHASE
  • NGX_HTTP_LOG_PHASE

each phase has a checker, nginx phase engine runs the checker with fixed order, inside each checker there could be several handlers, each checker runs handlers of that phase.

Note: phase is for client request(filter is for response), engine runs after parsing all request headers.

Read more »

Overview

After a request is served, we need to free resource used by that request, nginx provides two main API(high level) to free downstream and upstream side.

  • ngx_http_finalize_request: free request and client connection etc
  • ngx_http_upstream_finalize_request: free upstream peer resource etc

Note: not always both APIs called for each request, it depends on config and phase it’s in, call proper API(some time lower level API) to free resource.

Read more »

Overview

upstream holds the backend information, how to select backend and free the peer connection based on balance algorithm.

explicit upstream defined in this way.

1
2
3
4
5
6
7
8
upstream up_1 {
ip_hash;
server 1.1.1.1:443 weight=1;
server 1.1.1.1:443 weight=2;
}
location /abc {
proxy_pass: https://up_1;
}

There is also another way to define an upstream called implicit upstream, for implicit upstream, there is no way to define balance algorithm(round robin is used) and set parameters for it.

1
2
3
location /abc {
proxy_pass: https://www.google.com/;
}
Read more »