Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Update weave-kube docs and YAML files to leverage Launch Generator #2903

Merged
merged 2 commits into from
May 26, 2017

Conversation

marccarre
Copy link
Contributor

@marccarre marccarre commented Apr 18, 2017

Context:

The current Kubernetes YAML for weave-kube

  1. is static, which forces people to manually edit the file in order to customise it, to add environment variables, etc. and
  2. exists in two versions, one for Kubernetes v1.5, and one for v1.6 and above, which forces users to make choices about how they install weave-kube, hence increasing mental burden.

The latest version of the Launch Generator supports, among others:

  • passing additional options, arguments, and environment variables (weaveworks/launch-generator#66), which addresses 1. above;
  • passing the output of kubectl version to automatically extract Kubernetes' "server version" and return appropriate YAML configuration (weaveworks/launch-generator#79) without having users to care about it, which addresses 2. above.

Changelog:

  1. Update documentation to cover point 1. from the above "Context" section.
  2. Update documentation to cover point 2. from the above "Context" section.
  3. Update Weave-Kube daemonset YAML files to standardise configuration based on Launch Generator's output.

Related work:

  • weaveworks/launch-generator#66
  • weaveworks/launch-generator#79
  • weaveworks/launch-generator#88
  • weaveworks/launch-generator#91

This PR and the above ones:

cc: @errordeveloper

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch 14 times, most recently from 819a1d0 to e01f43e Compare April 21, 2017 12:24
@weaveworksbot
Copy link

Documentation changes:

modified kube-addon

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from e01f43e to bfd095d Compare April 25, 2017 10:24
labels:
name: weave-net
name: weave-net
annotations:
cloud.weave.works/launcher-info: |-

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

- name: weavedb
mountPath: /weavedb
emptyDir: {}

This comment was marked as abuse.

This comment was marked as abuse.

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from bfd095d to 93f4450 Compare May 2, 2017 10:51
labels:
name: weave-net
name: weave-net
annotations:
cloud.weave.works/launcher-info: |-

This comment was marked as abuse.

spec:
template:
metadata:
kind: List

This comment was marked as abuse.

"email-address": "[email protected]"
}
apiVersion: v1
kind: ServiceAccount

This comment was marked as abuse.

name: weave-net
namespace: kube-system
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

```

After a few seconds, a Weave Net pod should be running on each
Node and any further pods you create will be automatically attached to the Weave
network.

**Note:** In Kubernetes versions `1.6` and above, depending on how your cluster is configured, you may need to:

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

- add `sudo`,
- add `--kubeconfig /etc/kubernetes/admin.conf` (or equivalent),

to the above `kubectl version` command.

This comment was marked as abuse.

This comment was marked as abuse.

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch 3 times, most recently from 53a179c to 8180b0d Compare May 8, 2017 09:54
@bboreham bboreham added this to the 2.0 milestone May 16, 2017
@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch 2 times, most recently from 7642edc to 4016409 Compare May 16, 2017 15:25
@bboreham
Copy link
Contributor

One thought: on release, we need to update the git.io short URLs, but there is no way to synchronise that with the release.

I guess it's ok if we update the static files first, then update the short URLs, and the docs are wrong about the mapping in the meantime.

@@ -62,6 +62,32 @@ Shut down Kubernetes, and _on all nodes_ perform the following:
Then relaunch Kubernetes and install the addon as described
above.

**Note:** You can customise the generated YAML file by passing Weave Net's options, arguments and environment variables as query parameters:

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from 4016409 to 42e1757 Compare May 22, 2017 13:31
@marccarre
Copy link
Contributor Author

If we proceed in the order described below, though, it should be OK?
There will indeed be a window of time during which things will be inconsistent with "Note: URLs", but I suspect very few people will read this and most will stop at the main instructions?

  1. Release LG
    No one uses /k8s/net and /k8s.yaml (cloud) doesn't include Net, so serving 2.0's YAML before 2.0 is actually released should be fine.
  2. Release Net, static files and docs (normal Net release process)
    a. people following the new docs will then start to use the LG, which serves up-to-date YAML. Again, I suspect most people will ignore "Note: URLs"
    b. people having scripted something based on the git.io short URLs will point to the static files, themselves just a copy of what the LG generates, i.e. 2.0's YAML
  3. Update git.io short URLs to point to the LG -- when this is eventually done by GitHub's support, then "Note: URLs" will finally be consistent.

Alternatively we could just keep the git.io short URLs pointing to the static files and remove "Note: URLs", but I did it this way because we apparently wanted to have all users leverage the LG.

```
$ kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')&env.MTU=1337"
```
This command -- notice `&env.MTU=1337` at the end of the URL -- generates a YAML file containing, among others:

This comment was marked as abuse.

This comment was marked as abuse.

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from 42e1757 to 18992bf Compare May 22, 2017 14:50
- name: IPALLOC_RANGE
value: 10.0.0.0/16
```
- `version`: Weave Net's version. Default: latest release.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham
Copy link
Contributor

If we proceed in the order described below, though, it should be OK?

Yes; I was just musing about the lack of synchronisation and the docs being wrong in the interim.

@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from 18992bf to 2598e86 Compare May 23, 2017 11:06
@bboreham
Copy link
Contributor

cc @abuehrle if you want to review the docs changes

@marccarre
Copy link
Contributor Author

N.B.: I'll fix the conflicts once weaveworks/launch-generator/issues/106 and weaveworks/launch-generator/issues/107 have been approved, and will simply re-generate the YAML files using the Launch Generator.

Copy link
Contributor

@abuehrle abuehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some changes around the YAML to download and edit based on the version of Net you have set.

Historic versions are archived on our [GitHub release
page](https://github.com/weaveworks/weave/releases).
**Note:** URLs:

This comment was marked as abuse.

- [https://git.io/weave-kube-1.6](https://git.io/weave-kube-1.6)

point respectively to:

This comment was marked as abuse.

- [https://cloud.weave.works/k8s/v1.6/net](https://cloud.weave.works/k8s/v1.6/net).

In the past, these URLs were pointing to static YAML files for the [latest release](https://github.com/weaveworks/weave/releases/tag/latest_release) of the Weave Net addon, respectively:

This comment was marked as abuse.


Some parameters are changed by environment variables; these can be
inserted into the YAML file like this:
If you are getting your YAML file from `cloud.weave.works` as described above, then you can customise it by passing some of Weave Net's options, arguments and environment variables as query parameters:

This comment was marked as abuse.

value: 10.0.0.0/16
```
- `version`: Weave Net's version. Default: `latest`, i.e. latest release. *WARNING*: Backward compatibility of the YAML is not guaranteed. If you lock Weave Net's version using something else than `latest` for this query parameter, please make sure you do so with the latest release, save a copy of the YAML and use this copy instead of downloading it every time from `cloud.weave.works`.
- `known-peers`: comma-separated list of hosts. Default: empty.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

#### Manually editing the YAML file

Whether you saved the YAML file served at `cloud.weave.works` or downloaded a static YAML file from our [releases page](https://github.com/weaveworks/weave/releases), you can manually edit it to suit your needs.

This comment was marked as abuse.

@bboreham bboreham force-pushed the issues/2754-launch-generator-for-net branch from 170ab1c to c4ba7de Compare May 25, 2017 14:48
securityContext:
privileged: true
volumeMounts:
seLinuxOptions:

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

marccarre added 2 commits May 26, 2017 14:17
Details:
- Update weave-kube docs to avoid explicit versioning by leveraging the Launch Generator.
- Update weave-kube docs to mention YAML customisation via the Launch Generator.
- Warn about potential backward incompatibility of the generated YAML, and how to ensure YAML and Net versions are compatible.
Note that given the YAML's structure is different from previous version, indentation of `COVERAGE_ARGS` had to change (+4 whitespaces to each line).
Commands used:
```
$ curl -fsS https://frontend.dev.weave.works/k8s/v1.5/net?v=latest > prog/weave-kube/weave-daemonset.yaml
$ curl -fsS https://frontend.dev.weave.works/k8s/v1.6/net?v=latest > prog/weave-kube/weave-daemonset-k8s-1.6.yaml
```
Annotations removed from Launch Generator's files:
```
      annotations:
        cloud.weave.works/launcher-info: |-
          {
            "server-version": "master-050965d",
            "original-request": {
              "url": "/k8s/v1.6/net?v=latest",
              "date": "Thu May 25 2017 13:16:43 GMT+0000 (UTC)"
            },
            "email-address": "[email protected]"
          }
```
and
```
      annotations:
        cloud.weave.works/launcher-info: |-
          {
            "server-version": "master-050965d",
            "original-request": {
              "url": "/k8s/v1.5/net?v=latest",
              "date": "Thu May 25 2017 13:16:43 GMT+0000 (UTC)"
            },
            "email-address": "[email protected]"
          }
```
@marccarre marccarre force-pushed the issues/2754-launch-generator-for-net branch from c4ba7de to 067ce6d Compare May 26, 2017 13:19
@marccarre
Copy link
Contributor Author

YAML for Kubernetes 1.5 seems to work fine:

master$ sudo kubeadm reset && sudo rm -r -f /opt/cni/bin/*weave*
master$ k8s_version="$(kubelet --version | grep -oP "(?<=Kubernetes )v[\d\.\-beta]+")"
master$ k8s_version_option="$([[ "$k8s_version" > "v1.6" ]] && echo "kubernetes-version" || echo "use-kubernetes-version")"
master$ sudo systemctl start kubelet && sudo kubeadm init --$k8s_version_option=$k8s_version
master$ git clone https://github.com/weaveworks/weave.git && cd weave && git checkout issues/2754-launch-generator-for-net

worker$ sudo kubeadm reset && sudo rm -r -f /opt/cni/bin/*weave*
worker$ sudo systemctl start kubelet && sudo kubeadm join --token=260b6a.c036d577c3919d8f 10.128.0.5

master$ kubectl apply -f prog/weave-kube/weave-daemonset.yaml
serviceaccount "weave-net" created
daemonset "weave-net" created

master$ kubectl get po --all-namespaces
NAMESPACE     NAME                              READY     STATUS    RESTARTS   AGE
default       weave-net-9jsr1                   2/2       Running   0          1m
default       weave-net-bh8fk                   2/2       Running   0          1m
default       weave-net-ch6hr                   2/2       Running   0          1m
kube-system   dummy-2088944543-m3rnp            1/1       Running   0          3m
kube-system   etcd-k15-0                        1/1       Running   0          2m
kube-system   kube-apiserver-k15-0              1/1       Running   2          2m
kube-system   kube-controller-manager-k15-0     1/1       Running   0          2m
kube-system   kube-discovery-1769846148-l8918   1/1       Running   0          3m
kube-system   kube-dns-2924299975-xwbzc         4/4       Running   0          3m
kube-system   kube-proxy-flgk8                  1/1       Running   0          2m
kube-system   kube-proxy-l6v5n                  1/1       Running   0          2m
kube-system   kube-proxy-n32vx                  1/1       Running   0          3m
kube-system   kube-scheduler-k15-0              1/1       Running   0          2m

hosts$ curl -sS http://127.0.0.1:6784/status
        Version: git-4f20f545dc44 (up to date; next check at 2017/05/26 18:49:28)

        Service: router
       Protocol: weave 1..2
           Name: XX:XX:XX:XX:XX:XX(k15-0|1|2)
     Encryption: disabled
  PeerDiscovery: enabled
        Targets: 3
    Connections: 3 (2 established, 1 failed)
          Peers: 3 (with 6 established connections)
 TrustedSubnets: none

        Service: ipam
         Status: ready
          Range: 10.32.0.0/12
  DefaultSubnet: 10.32.0.0/12

master$ kubectl run nettest --image=weaveworks/network-tester:latest --replicas=3 -- -peers=3 -dns-name=nettest.default.svc.cluster.local.
deployment "nettest" created

master$ kubectl get po
NAME                       READY     STATUS    RESTARTS   AGE
nettest-4020221811-rr8nm   1/1       Running   0          33s
nettest-4020221811-tj4k3   1/1       Running   0          33s
nettest-4020221811-vq7r0   1/1       Running   0          33s
weave-net-9jsr1            2/2       Running   0          6m
weave-net-bh8fk            2/2       Running   0          6m
weave-net-ch6hr            2/2       Running   0          6m

master$ kubectl create -f - <<EOF
> apiVersion: v1
> kind: Service
> metadata:
>   name: nettest
> spec:
>   clusterIP: None
>   ports:
>   - port: 80
>     targetPort: 8080
>     protocol: TCP
>   selector:
>     run: nettest
> EOF
service "nettest" created

master$ podIP=$(kubectl get pods -l run=nettest -o go-template='{{(index .items 0).status.podIP}}' 2>/dev/null)
master$ echo $podIP
10.32.0.3
master$ curl -s -S http://$podIP:8080/status
pass

@bboreham bboreham merged commit a5e4a19 into master May 26, 2017
@marccarre marccarre deleted the issues/2754-launch-generator-for-net branch June 1, 2017 10:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Launch generator for weave-kube
5 participants