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

Toolbox Templating Docs #3800

Merged
merged 1 commit into from
Nov 8, 2017
Merged

Conversation

gambol99
Copy link
Contributor

@gambol99 gambol99 commented Nov 8, 2017

  • adding additional documentation about the toolbox template command

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 8, 2017
@gambol99
Copy link
Contributor Author

gambol99 commented Nov 8, 2017

@KashifSaadat if you can

@gambol99
Copy link
Contributor Author

gambol99 commented Nov 8, 2017

/assign @chrislovecnm

@@ -30,6 +30,8 @@ spec:
- {{.awsRegion}}c
```

You can pass configuration such as an environment file by using the `--values PATH` command line option. Note `--values` is a slice so can defined multiple times; the configuration is overridden by each configuration file (so order is important assuming duplicating values); a use-case for this would be a default configuration which upstream clusters are override.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor corrections:

  • Note --values is a slice so can be defined multiple times
  • a use-case for this would be a default configuration which upstream clusters can override.


### Formatting

Formatting in golang templates is an pain! at the start or at the end of a statement can be infuriating to get right, so a `--format-yaml=true` *(defaults to false)* command line option has been added. This will first unmarshal the generated content *(performing a syntax verification)* and then marshal back the content removing all those nasty formatting issues, newlines etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicks:

  • Formatting in golang templates is a pain! At the..

Copy link
Contributor

@KashifSaadat KashifSaadat left a comment

Choose a reason for hiding this comment

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

Just little bits of rewording

LGTM!

- adding additional documentation about the toolbox template command
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 8, 2017
@chrislovecnm
Copy link
Contributor

chrislovecnm commented Nov 8, 2017

@gambol99 / @KashifSaadat it is good to add the label retest-not-required-docs-only so that e2e does not have to run twice.

@chrislovecnm
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrislovecnm

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 8, 2017
@chrislovecnm
Copy link
Contributor

/retest

@chrislovecnm
Copy link
Contributor

/test pull-kops-e2e-kubernetes-aws

@k8s-github-robot
Copy link

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit 3ec8f52 into kubernetes:master Nov 8, 2017
image: {{ default $image $node.image }}
machineType: {{ default $instance $node.machine_type }}
maxSize: {{ default "10" $node.max_size }}
minSize: {{ default "1" $node.min_size }}
Copy link

Choose a reason for hiding this comment

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

Sorry to resurrect an old PR, but where does $node come from in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arrh .. yes .. I probably shouldn't have included this .. It was a copy and paste from our deployment repo, where we using a common template for all instancegroup .. so our environment file would have something like

node_pools:
- name: compute
  min_size: 2
- name: ingress
  instance: t2.medium
{{- $base := . -}}
{{- $dns_zone := .dns_zone -}}
{{- $enable_bastion := .enable_bastion -}}
{{- $env := env "ENVIRONMENT" -}}
{{- $image := .coreos_version -}}
{{- $instance := .compute_size -}}
{{- $size := .compute_root -}}
{{- $subnets := .compute_subnets -}}
{{- range $index, $node := .node_pools -}}
{{- if $index }}
---
{{ end }}apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: {{ $env }}.{{ $dns_zone }}
  name: {{ $node.name }}
spec:
  {{- if (and (eq $enable_bastion false) ($node.security_groups)) }}
  additionalSecurityGroups:
  {{- range $node.security_groups }}
  - {{ . }}
  {{- end }}
  {{- end }}
  cloudLabels:
    {{- if or (not $node.cloud_labels) (not (hasKey $node.cloud_labels "role")) }}
    role: {{ $node.name }}
    {{- end }}
    {{- if $node.cloud_labels }}
    {{- range $name, $value := $node.cloud_labels }}
    {{ $name }}: {{ $value }}
    {{- end }}
    {{- end }}
  image: {{ default $image $node.image }}
  machineType: {{ default $instance $node.machine_type }}
  maxSize: {{ default "10" $node.max_size }}
  minSize: {{ default "1" $node.min_size }}
  nodeLabels:
    {{- if or (not $node.node_labels) (not (hasKey $node.node_labels "role")) }}
    role: {{ $node.name }}
    {{- end }}
    {{- if $node.node_labels }}
    {{- range $name, $value := $node.node_labels }}
    {{ $name }}: {{ $value }}
    {{- end }}
    {{- end }}
  role: {{ default "Node" $node.role }}
  rootVolumeSize: {{ default $size $node.root_size }}
  subnets:
  {{- $networks := default $subnets $node.subnets }}
  {{- range $networks }}
  {{- if typeIs "map[string]interface {}" . }}
  - {{ .name }}
  {{- else }}
  - {{ . }}
  {{- end }}
  {{- end }}
  {{- if $node.taints }}
  taints:
  {{- range $node.taints }}
  - {{ .}}
  {{- end }}
  {{- end }}
{{- end }}

Copy link

Choose a reason for hiding this comment

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

I thought it might be something like that, and that example was what I was after. Thanks for sharing!

@gambol99 gambol99 deleted the template_docs branch June 25, 2018 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants