Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest templates #1884

Merged
merged 1 commit into from
Apr 18, 2018
Merged

Conversation

spikecurtis
Copy link
Contributor

Description

Reworks generation of various calico.yaml and canal.yaml manifests to be generated with Jekyll's templating system.

Todos

  • Tests

Release Note

None required

@spikecurtis spikecurtis requested a review from ozdanborne April 12, 2018 23:28
@spikecurtis
Copy link
Contributor Author

@ozdanborne you can just look at the second commit in this series

@ozdanborne
Copy link
Member

@spikecurtis Just wanted to bring up whitespace trimming:

In Liquid, you can include a hyphen in your tag syntax {{-, -}}, {%-, and -%} to strip whitespace from the left or right side of a rendered tag.

There's some places in the manifest where you've put if statements on their own line. By adding a whitespace trimmer, there won't be a blank line in the rendered manifests.

Other places, some of the if logic can be indented and on different lines if you use the whitespace trimmers, making it easier to read.

I'll make some individual comments to point out examples.

@ozdanborne
Copy link
Member

When do you plan to get this in? You may want to announce a freeze on manifest changes soon, otherwise you'll have a hard time rebasing.

@@ -0,0 +1,127 @@
# This ConfigMap is used to configure a self-hosted {{include.prodname}} installation.
Copy link
Member

Choose a reason for hiding this comment

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

How about a jekyll comment at the top of each of these include manifests that explains which .include flags it accepts. For this manifest, for example:

{% comment %}

calico-config.yaml acccepts the following include flags:

| Name        | Accepted Values |
|-------------|-----------------|
| datastore   | kdd, etcd       |
| typha       | true, false     |
| network     | calico, flannel |
| calico_ipam | true, false     |

{% endcomment %}

@spikecurtis
Copy link
Contributor Author

I planned on getting it in ASAP. I'm assuming that CNX doesn't use these manifests (or not master, at any rate).

image: docker.io/istio/proxy_init:0.6.0
args:
- "-p"
- {{ .MeshConfig.ProxyListenPort }}
Copy link
Member

@ozdanborne ozdanborne Apr 13, 2018

Choose a reason for hiding this comment

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

I think jekyll is going to try to render this. So you'll need to put it in a {% raw %}{{ .MeshConfig.ProxyListenPort }}{% endraw %}

Copy link
Member

Choose a reason for hiding this comment

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

Never mind! Looks like you did above 👍

@ozdanborne
Copy link
Member

ozdanborne commented Apr 13, 2018

I'm worried that Canal and Calico are too different to control with if/else. Perhaps we want to split the configmap into calico-config.yaml and canal-config.yaml, and consider doing the same for the Daemonset as well.

Edit: I'm less certain about splitting the daemonset but the calico-config and canal-config seem like it would be a clean way to simplify it.

@spikecurtis
Copy link
Contributor Author

spikecurtis commented Apr 13, 2018

Canal + etcd seems to be the odd one. Canal + KDD is very similar to Calico + KDD.

I was wondering if it is really necessary to be that way, and maybe Canal + etcd just never got updated...

# No IP address needed.
- name: IP
value: ""
{% else %}
Copy link
Member

@ozdanborne ozdanborne Apr 13, 2018

Choose a reason for hiding this comment

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

This 'else' is for the if include.network == 'calico' on line 112. It is quite difficult to track that down since these if statements aren't indented.

Since I don't think jekyll has a way for us to indent the if/else logic, perhaps we should avoid nested if statements and long if/else conditions when possible, instead opting to end them and explitly starting a new if with its exact conditions. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've indented nested logic and used {%- to prevent the nesting whitespace from showing up in the final rendered file.

@spikecurtis spikecurtis force-pushed the manifest-templates branch 2 times, most recently from 74740cf to 61bce5c Compare April 17, 2018 20:54
@@ -0,0 +1,19 @@
# This NetworkPolicy allows pods egress access the to
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this is in manifests/ instead of manifests/app-layer-policy?

Same for the other few manifests here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea

{%- endif %}
{%- if include.network == "calico" %}
# Configure the {{site.prodname}} backend to use.
calico_backend: "bird"
Copy link
Member

Choose a reason for hiding this comment

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

not super important, but this is smushing with typha_service_name in the kdd manifest:

data:
  # To enable Typha, set this to "calico-typha" *and* set a n
  # below.  We recommend using Typha if you have more than 50
  # essential.
  typha_service_name: "none"
  # Configure the Calico backend to use.
  calico_backend: "bird"

Copy link
Member

Choose a reason for hiding this comment

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

never mind, forget i mentioned this. there's a few places i'm seeing this, but we can fix it later.

namespace: kube-system
data:
# Configure this with the location of your etcd cluster.
etcd_endpoints: "https://127.0.0.1:2379"
Copy link
Member

Choose a reason for hiding this comment

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

interestingly, looks like canal etcd used https instead of http. I wouldn't have thought that https would work...

kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
name: canal-node
Copy link
Member

Choose a reason for hiding this comment

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

looks like the name of the daemonset changes to canal (instead of canal-node) in the new manifests. This would break upgrades for existing users applying our manifests directly...

hostNetwork: true
tolerations:
# Make sure canal node can be scheduled on all nodes.
- effect: NoSchedule
Copy link
Member

Choose a reason for hiding this comment

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

looks like we lost this toleration in the new canal manifest. Not sure what our stance is on running kube-controllers on master...

Copy link
Contributor Author

@spikecurtis spikecurtis Apr 17, 2018

Choose a reason for hiding this comment

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

Casey's stance is

¯\_(ツ)_/¯

# The default IPv4 pool to create on startup if none exists. Pod IPs will be
# chosen from this range. Changing this value after installation will have
# no effect. This should fall within `--cluster-cidr`.
- name: CALICO_IPV4POOL_CIDR
Copy link
Member

@ozdanborne ozdanborne Apr 17, 2018

Choose a reason for hiding this comment

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

The pool is still needed when net=none, as felix uses it to identify container traffic. So this needs to be moved into its own if statement where include.network == "calico" || include.network == "none"

- name: CALICO_IPV4POOL_CIDR
value: "192.168.0.0/16"
# Enable IPIP
- name: CALICO_IPV4POOL_IPIP
Copy link
Member

Choose a reason for hiding this comment

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

looks like we've dropped this field in the new system. which feels right. but just pointing out for the record 👍

@ozdanborne
Copy link
Member

Ok I've manually gone through all the diffs and pointed out all the major differences I found.

I've also attached the bash script I used to generate local manifests for comparisons, in case anyone else wants to compare them. (uploaded as .txt since github doesn't like .sh. just rename it).
render-comparable-manifests.txt

- apiGroups: [""]
resources: ["endpoints", "pods", "services"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
Copy link
Member

@ozdanborne ozdanborne Apr 17, 2018

Choose a reason for hiding this comment

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

Nit: this block and the previous block could be combined, since they share the exact same verbs and apiGroups:

- apiGroups: [""]
  resources: ["endpoints", "pods", "services", "namespaces", "nodes", "secrets"]
  verbs: ["get", "list", "watch"]

metadata:
name: istio-sidecar-injector-istio-system
rules:
- apiGroups: ["*"]
Copy link
Member

Choose a reason for hiding this comment

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

should be [""]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather not modify the istio.yaml since it's mostly taken from the Istio project directly, so us fixing it up is going to make merges difficult in the future.

- apiGroups: [""]
resources: ["serviceaccounts"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
Copy link
Member

Choose a reason for hiding this comment

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

this could be combined with the previous group as well

- name: istio-certs
secret:
optional: true
{% raw %}{{ if eq .Spec.ServiceAccountName "" }}secretName: istio.default{{ else }}secretName: {{ printf "istio.%s" .Spec.ServiceAccountName }}{{ end }}{% endraw %}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this raw is needed at all. It's currently rendering like this, which doesn't seem right:

        secret:
          optional: true
          {{ if eq .Spec.ServiceAccountName "" }}secretName: istio.default{{ else }}secretName: {{ printf "istio.%s" .Spec.ServiceAccountName }}{{ end }}

Copy link
Member

@ozdanborne ozdanborne Apr 17, 2018

Choose a reason for hiding this comment

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

If this is supported my mind is going to explode. Does kubectl support templating of the manifests themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, kubectl doesn't but the pod that consumes this configmap is itself a kind of templating engine. That's why this configmap has template tags in it that need to be escaped.

Copy link
Member

Choose a reason for hiding this comment

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

ohh, i didn't notice this was just technically a string inside a configmap. phew. Though i kind of wish it did work that way 😄

So we can dismiss the original comment, it's fine as is.

@spikecurtis spikecurtis merged commit eb339b4 into projectcalico:master Apr 18, 2018
@spikecurtis spikecurtis deleted the manifest-templates branch April 18, 2018 20:35
@caseydavenport caseydavenport changed the title [Do not merge] Manifest templates Manifest templates Apr 18, 2018
dghubble added a commit to poseidon/terraform-render-bootstrap that referenced this pull request Aug 15, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/terraform-render-bootstrap that referenced this pull request Aug 15, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 15, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/terraform-render-bootstrap that referenced this pull request Aug 15, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 15, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/terraform-render-bootstrap that referenced this pull request Aug 25, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 25, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 25, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
dghubble added a commit to poseidon/terraform-render-bootstrap that referenced this pull request Aug 26, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
tegamckinney pushed a commit to flexdrive/terraform-render-bootkube that referenced this pull request Dec 4, 2018
* Most upstream changes were buried in calico#1884 which
switched from non-templated manifests to templating
* projectcalico/calico#1884
* projectcalico/calico#1853
* projectcalico/calico#2069
* projectcalico/calico#2032
* projectcalico/calico#1841
* projectcalico/calico#1770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants