Merge pull request #2588 from weaveworks/kube-npc-docs
Document k8s addon & prometheus metrics
This commit is contained in:
commit
d356e32bdf
4 files changed
+232
No files matched your search
@@ -3,6 +3,11 @@ title: Integrating Kubernetes and Mesos via the CNI Plugin
|
||||
menu_order: 65
|
||||
---
|
||||
|
||||
> The recommended way of using Weave with Kubernetes is via the new
|
||||
> [Kubernetes Addon](/site/kube-addon.md). The instructions below
|
||||
> remain valid however, and are still the recommended method for
|
||||
> integrating with Mesos.
|
||||
|
||||
CNI, the [_Container Network Interface_](https://github.com/containernetworking/cni),
|
||||
is a proposed standard for configuring network interfaces for Linux
|
||||
application containers. CNI is supported by
|
||||
|
||||
@@ -11,6 +11,7 @@ menu_order: 20
|
||||
* [Address Allocation (IPAM)](#addressing)
|
||||
* [Naming and Discovery](#naming-and-discovery)
|
||||
* [Application Isolation](#application-isolation)
|
||||
* [Network Policy](#network-policy)
|
||||
* [Dynamic Network Attachment](#dynamic-network-attachment)
|
||||
* [Security](#security)
|
||||
* [Host Network Integration](#host-network-integration)
|
||||
@@ -139,6 +140,11 @@ See [Isolating Applications](/site/using-weave/application-isolation.md)
|
||||
for information on how to use the isolation-through-subnets
|
||||
technique with Weave Net.
|
||||
|
||||
###<a name="network-policy"></a>Network Policy
|
||||
|
||||
The Weave [Kubernetes Addon](/site/kube-addon.md) includes a network
|
||||
policy controller that implements [Kubernetes Network
|
||||
Policies](http://kubernetes.io/docs/user-guide/networkpolicies/).
|
||||
|
||||
###<a name="dynamic-network-attachment"></a>Dynamic Network Attachment
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: Integrating Kubernetes via the Addon
|
||||
menu_order: 63
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
If you're using Kubernetes 1.4 or later, and it is configured to use
|
||||
CNI, it is possible to install Weave Net on your cluster with a single
|
||||
command:
|
||||
|
||||
```
|
||||
kubectl create -f https://git.io/weave-kube
|
||||
```
|
||||
|
||||
After a few seconds, you should have a Weave Net pod running on each
|
||||
node, and any further pods you create will be attached to the Weave
|
||||
network.
|
||||
|
||||
> If you do not already have a CNI-enabled cluster, you can bootstrap
|
||||
> one easily with
|
||||
> [kubeadm](http://kubernetes.io/docs/getting-started-guides/kubeadm/);
|
||||
> alternatively if you are using the older cluster set-up scripts from
|
||||
> the Kubernetes repo, you can use
|
||||
>
|
||||
> ```
|
||||
> NETWORK_PROVIDER=cni cluster/kube-up.sh
|
||||
> ```
|
||||
|
||||
NB If you were previously using the [Weave CNI
|
||||
driver](/site/cni-plugin.md) from a full install of Weave Net with your
|
||||
cluster, you will need to uninstall it first. Shut down Kubernetes,
|
||||
then perform the following _on all nodes_:
|
||||
|
||||
* `weave reset`
|
||||
* Remove any separate provision you have made to run weave at
|
||||
boot-time, e.g. `systemd` units
|
||||
* `rm /opt/cni/bin/weave-*`
|
||||
|
||||
You can then relaunch Kubernetes and install the addon as described
|
||||
above.
|
||||
|
||||
The URL [https://git.io/weave-kube](https://git.io/weave-kube) points
|
||||
to the addon YAML for the latest release of the Weave Net addon;
|
||||
historic versions will be archived on our [GitHub release
|
||||
page](https://github.com/weaveworks/weave/releases).
|
||||
|
||||
## Upgrading
|
||||
|
||||
Kubernetes does not currently support rolling upgrades of daemon sets,
|
||||
so you will need to perform the procedure manually:
|
||||
|
||||
* Apply the updated addon manifest `kubectl apply -f https://git.io/weave-kube`
|
||||
* Kill each weave net pod in turn with kubectl delete; wait for the
|
||||
replacement to begin running before moving on to the next.
|
||||
|
||||
##<a name="npc"></a>Network Policy Controller
|
||||
|
||||
The addon supports the [Kubernetes policy
|
||||
API](http://kubernetes.io/docs/user-guide/networkpolicies/) so that
|
||||
you can securely isolate pods from each other based on namespaces and
|
||||
labels. For more information on configuring network policies in
|
||||
Kubernetes see the
|
||||
[walkthrough](http://kubernetes.io/docs/getting-started-guides/network-policy/walkthrough/)
|
||||
and the [NetworkPolicy API object
|
||||
definition](http://kubernetes.io/docs/api-reference/extensions/v1beta1/definitions/#_v1beta1_networkpolicy).
|
||||
|
||||
## Changing Configuration Options
|
||||
|
||||
You can change the default configuration by saving and editing the
|
||||
addon YAML before you `kubectl apply`. Additional arguments can be
|
||||
supplied to the Weave router process by adding them to the `command:`
|
||||
array in the yaml file.
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
---
|
||||
title: Monitoring with Prometheus
|
||||
menu_order: 105
|
||||
---
|
||||
|
||||
Two endpoints are exposed: one for the Weave Net router, and, when deployed as
|
||||
a [Kubernetes Addon](/site/kube-addon.md), one for the [network policy
|
||||
controller](/site/kube-addon.md#npc).
|
||||
|
||||
### Router Metrics
|
||||
|
||||
The endpoint address is `localhost:6782`; the following metrics are
|
||||
exposed:
|
||||
|
||||
* `weave_connections` - Number of peer-to-peer connections.
|
||||
* `weave_connection_terminations_total` - Number of peer-to-peer
|
||||
connections terminated.
|
||||
* `weave_ips` - Number of IP addresses.
|
||||
* `weave_max_ips` - Size of IP address space used by allocator.
|
||||
* `weave_dns_entries` - Number of DNS entries.
|
||||
* `weave_flows` - Number of FastDP flows.
|
||||
|
||||
### Kubernetes Network Policy Controller Metrics
|
||||
|
||||
The endpoint address is `localhost:6781`; the following metric is
|
||||
exposed:
|
||||
|
||||
* `weavenpc_blocked_connections_total` - Connection attempts blocked
|
||||
by policy controller.
|
||||
|
||||
# Static Configuration for Weave Net
|
||||
|
||||
The following YAML fragment can be used in your Prometheus configuration to
|
||||
scrape the router metrics endpoint:
|
||||
|
||||
```
|
||||
scrape_configs:
|
||||
- job_name: 'weave'
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['localhost:6782']
|
||||
```
|
||||
|
||||
# Discovery Configuration for Kubernetes
|
||||
|
||||
If you're running Weave in conjunction with Kubernetes, it is possible
|
||||
to discover the endpoints for all nodes automatically. The following
|
||||
Kubernetes config will install and configure Prometheus 1.3 on your
|
||||
cluster and configure it to discover and scrape the Weave endpoints:
|
||||
|
||||
```
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: prometheus
|
||||
data:
|
||||
prometheus.yml: |-
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
scrape_configs:
|
||||
- job_name: 'weave'
|
||||
kubernetes_sd_configs:
|
||||
- api_server:
|
||||
role: pod
|
||||
relabel_configs:
|
||||
- source_labels: [__meta_kubernetes_namespace,__meta_kubernetes_pod_label_name]
|
||||
action: keep
|
||||
regex: ^kube-system;weave-net$
|
||||
- source_labels: [__meta_kubernetes_pod_container_name,__address__]
|
||||
action: replace
|
||||
target_label: __address__
|
||||
regex: ^weave;(.+?)(?::\d+)?$
|
||||
replacement: $1:6782
|
||||
- source_labels: [__meta_kubernetes_pod_container_name,__address__]
|
||||
action: replace
|
||||
target_label: __address__
|
||||
regex: ^weave-npc;(.+?)(?::\d+)?$
|
||||
replacement: $1:6781
|
||||
- source_labels: [__meta_kubernetes_pod_container_name]
|
||||
action: replace
|
||||
target_label: job
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
name: prometheus
|
||||
name: prometheus
|
||||
spec:
|
||||
selector:
|
||||
app: prometheus
|
||||
type: NodePort
|
||||
ports:
|
||||
- name: prometheus
|
||||
protocol: TCP
|
||||
port: 9090
|
||||
nodePort: 30900
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: prometheus
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: prometheus
|
||||
template:
|
||||
metadata:
|
||||
name: prometheus
|
||||
labels:
|
||||
app: prometheus
|
||||
spec:
|
||||
containers:
|
||||
- name: prometheus
|
||||
image: prom/prometheus:v1.3.0
|
||||
args:
|
||||
- '-config.file=/etc/prometheus/prometheus.yml'
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: 9090
|
||||
volumeMounts:
|
||||
- name: config-volume
|
||||
mountPath: /etc/prometheus
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: prometheus
|
||||
```
|
||||
|
||||
# Weave Cloud Integration
|
||||
|
||||
Finally, you can configure your local Prometheus instance to push
|
||||
metrics to Weave Cloud by including the following fragment in the
|
||||
`prometheus.yml` above (after replacing `<WEAVE_CLOUD_TOKEN>` with
|
||||
your own token):
|
||||
|
||||
```
|
||||
remote_write:
|
||||
url: http://frontend.dev.weave.works/api/prom/push
|
||||
basic_auth:
|
||||
password: <WEAVE_CLOUD_TOKEN>
|
||||
```
|
||||
|
||||
For information on getting started with Weave Cloud metrics, including
|
||||
on how to obtain your Weave Cloud token, please go
|
||||
[here](https://github.com/weaveworks/cortex).
|
||||
Reference in new issue
Block a user