Skip to content

Commit

Permalink
refactor(devtools): consoldiate states
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 9, 2020
1 parent acab20b commit 4ae1c36
Show file tree
Hide file tree
Showing 35 changed files with 356 additions and 396 deletions.
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignore: |
kubernetes/osfamilymap.yaml
kubernetes/defaults.yaml
kubernetes/osarchmap.yaml
pillar.example
yaml-files:
# Default settings
Expand Down
56 changes: 40 additions & 16 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Formula to manage kubernetes on MacOS and GNU/Linux. Currently supports:
* `server`
* `node`
* `client`
* `client libs`
* `devspace`
* `istio`
* `kind`
Expand All @@ -19,7 +18,10 @@ Formula to manage kubernetes on MacOS and GNU/Linux. Currently supports:
* `minikube`
* `octant`
* `operators`
* `tools`
* `devtools`
* `devlibs`

Operators, Developer tools, and Developer library are easy to customize and extend.


|img_travis| |img_sr|
Expand Down Expand Up @@ -185,42 +187,64 @@ This state uninstalls istio only (see https://istio.io)
``kubernetes.octant``
^^^^^^^^^^^^^^^^^^^^^

This state installs octant only(see https://github.com/vmware-tanzu/octant)
This state installs octant only (see https://github.com/vmware-tanzu/octant)

``kubernetes.octant.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls octant only(see https://github.com/vmware-tanzu/octant)
This state uninstalls octant only (see https://github.com/vmware-tanzu/octant)

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

This state installs linkerd2 only(see https://github.com/linkerd/linkerd2)
This state installs linkerd2 only (see https://github.com/linkerd/linkerd2)

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

This state uninstalls linkerd2 only(see https://github.com/linkerd/linkerd2)
This state uninstalls linkerd2 only (see https://github.com/linkerd/linkerd2)

``kubernetes.operators``
^^^^^^^^^^^^^^^^^^^^^^^^

This state installs operator archives only (see https://operatorhub.io)
This state installs operator archives only

* https://operatorhub.io
* https://github.com/flant/shell-operator
* https://github.com/ahmetb/kubectx

``kubernetes.operators.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls operator archives only (see https://operatorhub.io)
This state uninstalls operator archives only

``kubernetes.tools``
^^^^^^^^^^^^^^^^^^^^
``kubernetes.devtools``
^^^^^^^^^^^^^^^^^^^^^^^

This state installs selected kubernetes developer tools (i.e. `kubectx`, `kubens`, etc)
This state installs selected kubernetes developer tools only

``kubernetes.tools.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^
* https://github.com/ahmetb/kubectx
* https://github.com/cuelang/cue
* https://github.com/liggitt/audit2rbac

``kubernetes.devtools.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls selected kubernetes developer tools only

``kubernetes.devlibs``
^^^^^^^^^^^^^^^^^^^^^^

This state installs selected kubernetes developer libraries

* https://github.com/kubernetes-client
* https://github.com/zalando-incubator/kopf
* https://github.com/ericchiang/k8s

``kubernetes.devlibs.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls selected kubernetes developer tools (i.e. `kubectx`, `kubens`, etc)
This state uninstalls selected kubernetes developer libraries (i.e. kubernetes client libraries, kopf, etc).


Main Sub-states
Expand All @@ -232,12 +256,12 @@ Main Sub-states
``kubernetes.minikube.package``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state installs minikube package only(MacOS).
This state installs minikube package only (MacOS).

``kubernetes.minikube.package.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This state uninstalls the minikube package only(MacOS).
This state uninstalls the minikube package only (MacOS).

``kubernetes.minikube.binary``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions kubernetes/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ include:
- .server.clean
- .client.clean
- .devtools.clean
- .devlibs.clean
1 change: 0 additions & 1 deletion kubernetes/client/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
include:
- .package.clean
- .binary.clean
- .libs.clean
1 change: 0 additions & 1 deletion kubernetes/client/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
include:
- {{ '.binary' if d.client.pkg.use_upstream_binary else '.archive' if d.client.pkg.use_upstream_archive else '.package' }}
- .libs
70 changes: 61 additions & 9 deletions kubernetes/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kubernetes:
- kudo
- minikube
- operators
- devlibs
- devtools

identity:
Expand All @@ -42,26 +43,61 @@ kubernetes:
gpgcheck: 1

devtools:
wanted:
- kubectx
- kubens
- cue
- audit2rbac
kubectx:
version: '0.9.1'
pkg:
use_upstream_archive: true
uri: https://github.com/ahmetb/kubectx/releases/download # set in map.jinja
uri: https://github.com/ahmetb/kubectx/releases/download
suffix: tar.gz
commands:
- kubectx
archive:
path: null # set in map.jinja
source: null # set in map.jinja
source_hash: ce689516f3ae916492bb8f9ee3344da03f6b5a098c1ce2c4a5107b8e9e1cf445 # x86_64
kubens:
version: '0.9.1'
pkg:
use_upstream_archive: true
uri: https://github.com/ahmetb/kubectx/releases/download # set in map.jinja
uri: https://github.com/ahmetb/kubectx/releases/download
suffix: tar.gz
commands:
- kubens
archive:
source: null # set in map.jinja
path: null # set in map.jinja
source_hash: dea7839158e4847b8b52709dbfbe9ff2d974df4416b8ea8a86ce4bd622786f52 # x86_64
cue:
version: '0.2.1'
pkg:
use_upstream_archive: true
name: cue
uri: https://github.com/cuelang/cue/releases/download
suffix: tar.gz
commands:
- cue
archive:
path: null # set in map.jinja
source: null # set in map.jinja
source_hash: 40078d02559595eec8e5a873f09ca89545502019bcac6f892f5a30bb8d49286c # x86_64
audit2rbac:
version: '0.8.0'
pkg:
use_upstream_archive: true
name: audit2rbac
uri: https://github.com/liggitt/audit2rbac/releases/download
suffix: tar.gz
commands:
- audit2rbac
archive:
path: null # set in map.jinja
source: null # set in map.jinja
source_hash: 819361a9b61ce02dc86bbe789b1da54dd887c2841f1a92ed0abb790738efc7f2 # x86_64

client:
version: 1.18.0
Expand Down Expand Up @@ -91,27 +127,43 @@ kubernetes:
source: null # set in map.jinja
source_hash: 6ea8261b503c6c63d616878837dc70b758d4a3aeb9996ade8e83b51aedac9698
trim_output: true
libs:
wanted:
- java
- python
- csharp
- javascript
uri: https://github.com/kubernetes-client

devlibs:
wanted:
- java
- python
- csharp
- javascript
- kopf
- k8s
pkg:
java:
name: 'client-java-parent-'
version: '6.0.1'
uri: https://github.com/kubernetes-client
source_hash: '51d0229a80b913ede5a973036e7c78c36efc1d425c3ccde10f81acb03e183aa2'
python:
name: v
version: '11.0.0'
uri: https://github.com/kubernetes-client
source_hash: '3ec0a0887bef32589ebb46efe7fbd30758c1da3c37f28d4394e9f4620172951a'
csharp:
version: '1.2.0'
uri: https://github.com/kubernetes-client
source_hash: '0edcefd17f50d0e9d5b34ea318a6a5a13cf9448f918ffa9dec519da9457f9159'
javascript:
version: '0.10.1'
uri: https://github.com/kubernetes-client
source_hash: '9b7d2c7a2afd30fc6b42fc060fa64221de8221aa8211ffc8d275b1ac54b9717a'
kopf:
name: ''
version: '0.27'
uri: https://github.com/zalando-incubator/kopf/archive
source_hash: '25a98ca73b3e7ea8bc38dc31cd5e3f2bd6d443490395166b61eeaeb02d9e1d4d'
k8s:
version: '1.2.0'
uri: https://github.com/ericchiang/k8s/archive
source_hash: 18f4c90d7b206d9abb69aff007a534e6cf2e723cbc7d4bb74cc32ec619c418ca

operators:
# https:// operatorhub.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- if 'wanted' in d.client.libs and d.client.libs.wanted %}
{%- for lib in d.client.libs.wanted %}
{%- if 'libs' in d.client and lib in d.client.libs and d.client.libs[lib] %}
{%- if 'wanted' in d.devlibs and d.devlibs.wanted %}
{%- for lib in d.devlibs.wanted %}
{%- if lib in d.devlibs and d.devlibs[lib] %}
{{ formula }}-client-libs-clean-{{ lib }}:
{{ formula }}-devlibs-clean-{{ lib }}:
file.absent:
- name: {{ d.dir.source }}/{{ lib }}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- if 'wanted' in d.client.libs and d.client.libs.wanted %}
{%- for lib in d.client.libs.wanted %}
{%- if 'libs' in d.client and lib in d.client.libs and d.client.libs[lib] %}
{%- if 'wanted' in d.devlibs and d.devlibs.wanted %}
{%- for lib in d.devlibs.wanted %}
{%- if lib in d.devlibs and d.devlibs[lib] %}
{{ formula }}-client-libs-install-{{ lib }}:
{{ formula }}-devlibs-lib-install-{{ lib }}:
file.directory:
- name: {{ d.dir.source }}/{{ lib }}
- user: {{ d.identity.rootuser }}
Expand All @@ -18,15 +18,15 @@
- clean: True
- makedirs: True
- require_in:
- archive: {{ formula }}-client-libs-install-{{ lib }}
- archive: {{ formula }}-devlibs-lib-install-{{ lib }}
- recurse:
- user
- group
- mode
archive.extracted:
- name: {{ d.dir.source }}/{{ lib }}
- source: {{ d.client.libs[lib]['source'] }}
- source_hash: {{ d.client.libs[lib]['source_hash'] }}
- source: {{ d.devlibs[lib]['source'] }}
- source_hash: {{ d.devlibs[lib]['source_hash'] }}
- retry: {{ d.retry_option }}
- enforce_toplevel: false
- options: '--strip-components=1'
Expand Down
34 changes: 34 additions & 0 deletions kubernetes/devtools/alternatives/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- if grains.kernel|lower == 'linux' and grains.os_family not in ('Arch',) %}

{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- set sls_archive_clean = tplroot ~ '.devtools.clean' %}
include:
- {{ sls_archive_clean }}
{%- if 'wanted' in d.devtools and d.devtools.wanted %}
{%- for tool in d.devtools.wanted %}
{%- if tool in d.devtools and d.devtools[tool] %}
{%- if d.devtools[tool]['pkg']['use_upstream_archive'] and d.linux.altpriority|int > 0 %}
{%- for cmd in d.devtools[tool]['pkg']['commands'] %}
{{ formula }}-devtools-{{ tool }}-archive-alternatives-clean-{{ cmd }}:
alternatives.remove:
- name: link-k8s-devtools-{{ tool }}-{{ cmd }}
- path: {{ d.devtools[tool]['pkg']['archive']['path'] }}/{{ cmd }}
- onlyif: update-alternatives --get-selections |grep ^link-k8s-devtools-{{ tool }}-{{ cmd }}
- require:
- sls: {{ sls_archive_clean }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
File renamed without changes.
49 changes: 49 additions & 0 deletions kubernetes/devtools/alternatives/install.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- if grains.kernel|lower == 'linux' and grains.os_family not in ('Arch',) %}

{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- set sls_archive_install = tplroot ~ '.devtools.install' %}
include:
- {{ sls_archive_install }}
{%- if 'wanted' in d.devtools and d.devtools.wanted %}
{%- for tool in d.devtools.wanted %}
{%- if tool in d.devtools and d.devtools[tool] %}
{%- if d.devtools[tool]['pkg']['use_upstream_archive'] and d.linux.altpriority|int > 0 %}
{%- for cmd in d.devtools[tool]['pkg']['commands'] %}
{{ formula }}-devtools-{{ tool }}-archive-alternatives-install-{{ cmd }}:
alternatives.install:
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- name: link-k8s-devtools-{{ tool }}-{{ cmd }}
- link: /usr/local/bin/{{ cmd }}
- path: {{ d.devtools[tool]['pkg']['archive']['path'] }}/{{ cmd }}
- priority: {{ d.linux.altpriority }}
- order: 10
- require:
- sls: {{ sls_archive_install }}
cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-devtools-{{ tool }}-{{ cmd }} {{ d.devtools[tool]['pkg']['archive']['path'] }}/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
{{ formula }}-devtools-{{ tool }}-archive-alternatives-set-{{ cmd }}:
alternatives.set:
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- name: link-k8s-devtools-{{ tool }}-{{ cmd }}
- path: {{ d.devtools[tool]['pkg']['archive']['path'] }}/{{ cmd }}
- require:
- alternatives: {{ formula }}-devtools-{{ tool }}-archive-alternatives-install-{{ cmd }}
- sls: {{ sls_archive_install }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
Loading

0 comments on commit 4ae1c36

Please sign in to comment.