Skip to content

Commit

Permalink
feat(linkerd): add linkerd2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 9, 2020
1 parent 6565ac2 commit 80858a4
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Formula to manage kubernetes on MacOS and GNU/Linux. Currently supports:
* `kind`
* `k3s`
* `istio`
* `linkerd2`
* `kubebuilder`
* `minikube`
* `kudo`
Expand Down Expand Up @@ -178,6 +179,16 @@ This state installs istio only.

This state uninstalls istio only.

``kubernetes.linkerd2``
^^^^^^^^^^^^^^^^^^^^^^^

This state installs linkerd2 only.

``kubernetes.linkerd2.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls linkerd2 only.


Main Sub-states
---------------
Expand Down
10 changes: 9 additions & 1 deletion kubernetes/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ kubernetes:
# K3S_TOKEN: ''
# K3S_TOKEN_FILE: ''
# KUBECONFIG: /etc/rancher/k3s/k3s.yaml

kudo:
version: 0.12.0
pkg:
Expand All @@ -234,6 +233,15 @@ kubernetes:
name: kubectl-kudo
source: null # set in map.jinja
source_hash: 5df22a42021d78a199d00f055faedd47a86ad3001bd06da31549c0a477a403a9
linkerd2:
version: 20.7.1
pkg:
use_upstream_binary: true
binary:
uri: 'https://github.com/linkerd/linkerd2/releases/download'
name: linkerd2-cli-edge
source: null # set in map.jinja
source_hash: null # set in map.jinja
kind:
version: 0.8.1
pkg:
Expand Down
12 changes: 12 additions & 0 deletions kubernetes/linkerd2/binary/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{{ formula }}-linkerd2-binary-clean:
file.absent:
- names:
- /usr/local/bin/linkerd
- {{ d.linkerd2.pkg.binary.name }}/bin/linkerd
5 changes: 5 additions & 0 deletions kubernetes/linkerd2/binary/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#.-*- coding: utf-8 -*-
# vim: ft=sls

include:
- .install
47 changes: 47 additions & 0 deletions kubernetes/linkerd2/binary/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{{ formula }}-linkerd2-binary-install:
pkg.installed:
- names: {{ d.pkg.deps|json }}
file.directory:
- name: {{ d.linkerd2.pkg.binary.name }}/bin
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- makedirs: True
- require_in:
- cmd: {{ formula }}-linkerd2-binary-install
- recurse:
- user
- group
- mode
cmd.run:
- names:
- curl -Lo {{ d.linkerd2.pkg.binary.name }}/bin/linkerd {{ d.linkerd2.pkg.binary.source }}
- chmod '0755' {{ d.linkerd2.pkg.binary.name }}/bin/linkerd 2>/dev/null
- retry: {{ d.retry_option|json }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- if 'source_hash' in d.linkerd2.pkg.binary and d.linkerd2.pkg.binary.source_hash %}
module.run:
- name: file.check_hash
- path: {{ d.linkerd2.pkg.binary.name }}/bin/linkerd
- file_hash: {{ d.linkerd2.pkg.binary.source_hash }}
- require:
- cmd: {{ formula }}-linkerd2-binary-install
{%- endif %}
{{ formula }}-linkerd2-binary-install-symlink:
file.symlink:
- name: /usr/local/bin/linkerd
- target: {{ d.linkerd2.pkg.binary.name }}/bin/linkerd
- force: True
- require:
- cmd: {{ formula }}-linkerd2-binary-install
- unless:
- {{ d.linux.altpriority|int > 0 }}
5 changes: 5 additions & 0 deletions kubernetes/linkerd2/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .binary.clean
5 changes: 5 additions & 0 deletions kubernetes/linkerd2/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .binary
3 changes: 3 additions & 0 deletions kubernetes/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
{%- elif comp in ('minikube', 'devspace', 'kind') %}
{%- set uri = '%s/v%s/%s-%s-%s'|format(d[comp]['pkg']['binary']['uri'], d[comp]['version'],
comp, grains.kernel|lower, d.arch) %}
{%- elif comp in ('linkerd2',) %}
{%- set uri = '%s/edge-%s/linkerd2-cli-edge-%s-%s'|format(d[comp]['pkg']['binary']['uri'],
d[comp]['version'], d[comp]['version'], d.arch) %}
{%- elif comp == 'kudo' %}
{%- set arch = 'x86_64' if d.arch == 'amd64' else d.arch %}
{%- set uri = '%s/v%s/kubectl-%s_%s_%s_%s'|format(d[comp]['pkg']['binary']['uri'], d[comp]['version'],
Expand Down
2 changes: 2 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ kubernetes:
version: 0.12.0
kind:
version: 0.8.1
linkerd2:
version: 20.7.1
istio:
version: 1.6.4
kubebuiler:
Expand Down
10 changes: 10 additions & 0 deletions test/integration/default/controls/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@
it { should be_file }
it { should_not be_directory }
end
describe file('/usr/local/kubernetes-linkerd2-v20.7.1/bin/linkerd') do
it { should_not be_symlink }
it { should be_file }
it { should_not be_directory }
end
describe file('/usr/local/bin/linkerd') do
it { should be_symlink }
it { should be_file }
it { should_not be_directory }
end
describe file('/usr/local/kubernetes-istio-v1.6.4/bin/istioctl') do
it { should_not be_symlink }
it { should be_file }
Expand Down

0 comments on commit 80858a4

Please sign in to comment.