Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
@#31 | add k8s resource
Browse files Browse the repository at this point in the history
  • Loading branch information
hieptranquoc committed Apr 26, 2018
1 parent 4ec478d commit 1e00ccc
Show file tree
Hide file tree
Showing 55 changed files with 1,579 additions and 418 deletions.
16 changes: 16 additions & 0 deletions .idea/kubernetes-stack-cookbook.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

304 changes: 304 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
---
driver:
name: dokken
chef_version: latest
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
privileged: true # because Docker and SystemD/Upstart

transport:
name: dokken

provisioner:
name: dokken
deprecations_as_errors: true

verifier:
name: inspec

platforms:
- name: ubuntu-16.04
driver:
image: ubuntu:16.04
# pid_one_command: /bin/systemd
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get -y install curl lsb-release bash-completion
- name: centos-7
driver:
image: centos:7
privileged: true
# pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN yum -y install lsof which net-tools curl bash-completion

# - name: centos-7
# driver:
# image: dokken/centos-7
# pid_one_command: /usr/lib/systemd/systemd
50 changes: 24 additions & 26 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ verifier:

platforms:
- name: ubuntu-16.04
- name: centos-7.3
# - name: centos-7

suites:
- name: smoke-install-default
- name: smoke-install
run_list:
- recipe[kubernetes-stack-test::default]
- recipe[kubernetes-stack-test::install]
verifier:
inspec_tests:
- test/smoke/default/default_test.rb
- test/smoke/gcloud/gcloud_install_default_test.rb
- test/smoke/kubectl/kubectl_install_default_test.rb
- test/smoke/helm/helm_install_default_test.rb
- test/smoke/kubectl/kubectl_install_test.rb
- test/smoke/gcloud/gcloud_install_test.rb
- test/smoke/helm/helm_install_test.rb
- test/smoke/minikube/minikube_install_test.rb
attributes:
kubernetes-stack:
kubectl:
Expand All @@ -37,36 +39,25 @@ suites:
helm:
enabled: true,
version: ""

- name: smoke-install-specific-version
run_list:
- recipe[kubernetes-stack-test::install]
verifier:
inspec_tests:
- test/smoke/default/default_test.rb
- test/smoke/gcloud/gcloud_install_specific_version_test.rb
- test/smoke/kubectl/kubectl_install_specific_version_test.rb
- test/smoke/helm/helm_install_specific_version_test.rb
attributes:
kubernetes-stack:
kubectl:
minikube:
enabled: true,
version: "v1.7.0"
gcloud:
enabled: true,
version: "158.0.0"
helm:
enabled: true,
version: "v2.4.2"
version: "v0.25.2"
k8s_version: ""
network_plugin: "cni"
bootstrapper: "kubeadm"
vm_driver: "none"

- name: smoke-uninstall
run_list:
- recipe[kubernetes-stack-test::default]
- recipe[kubernetes-stack-test::uninstall]
verifier:
inspec_tests:
- test/smoke/default/default_test.rb
- test/smoke/gcloud/gcloud_uninstall_test.rb
- test/smoke/kubectl/kubectl_uninstall_test.rb
- test/smoke/helm/helm_uninstall_test.rb
- test/smoke/kubectl/kubectl_uninstall_test.rb
- test/smoke/minikube/minikube_uninstall_test.rb
attributes:
kubernetes-stack:
kubectl:
Expand All @@ -78,3 +69,10 @@ suites:
helm:
enabled: true,
version: ""
minikube:
enabled: true,
version: "v0.25.2"
k8s_version: ""
network_plugin: "cni"
bootstrapper: "kubeadm"
vm_driver: "none"
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
AllCops:
TargetRubyVersion: 2.4
Exclude:
- vendor/**/*
- Guardfile
Expand Down
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,28 @@ addons:
packages:
- chefdk

# Don't `bundle install` which takes about 1.5 mins
install: echo "skip bundle install"

services: docker

env:
matrix:
- INSTANCE=smoke-install-default-ubuntu-1604
- INSTANCE=smoke-install-default-centos-7
- INSTANCE=smoke-install-specific-version-ubuntu-1604
- INSTANCE=smoke-install-specific-version-centos-7
- INSTANCE=smoke-install-ubuntu-1604
# - INSTANCE=smoke-install-default-centos-7
- INSTANCE=smoke-uninstall-ubuntu-1604
- INSTANCE=smoke-uninstall-centos-7
# - INSTANCE=smoke-uninstall-centos-7

# Ensure we make ChefDK's Ruby the default
before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- chef gem install kitchen-dokken
- eval "$(/opt/chefdk/bin/chef shell-init bash)"

script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE}

matrix:
include:
- before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- script:
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/cookstyle --version
Expand Down
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

metadata
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please refer to https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

see:

- https://github.com/teracyhq-incubator/kubernetes-stack-cookbook/graphs/contributors
- https://github.com/teracyhq-incubator/kubernetes-stack-cookbook/graphs/contributors
91 changes: 78 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,24 @@ Kubernetes stack cookbook to work with Kubernetes: https://supermarket.chef.io/c

- `kubectl`: support all centos-7 and ubuntu-16.04 versions.
- `helm`: support all centos-7 and ubuntu-16.04 versions.
- `gcloud`: support all centos-7 and ubuntu-16.04 versions. Should use version avaiable in https://packages.cloud.google.com/apt/ (with ubuntu platform) for faster autocomplete.
- `gcloud`: support all centos-7 and ubuntu-16.04 versions.
- `minikube`: support all centos-7 and ubuntu-16.04 versions.

## Cookbook

- kubernetes-stack
- docker

## Requirement

- docker must be installed in machine
- `minikube` should be run with special user. You can change by override attributes in recipe:

```ruby
node.override['kubernetes-stack']['user'] = `user`
```

- or edit attributes in `default.rb` file

## How to use

Expand All @@ -26,19 +43,29 @@ Kubernetes stack cookbook to work with Kubernetes: https://supermarket.chef.io/c
kubectl 'install kubectl' do
action [:install, :remove]
version '' #application version (if empty, default: latest)
binary_path '' #application path (if empty, default: /usr/local/bin/kubectl)
path '' #application path (if empty, default: /usr/local/bin)
end

gcloud 'install gcloud' do
action [:install, :remove]
version '' #application version (if empty, default: latest)
binary_path '' #application path (if empty, default: /usr/local/bin/gcloud)
path '' #application path (if empty, default: /usr/local/bin)
end

helm 'install helm' do
action [:install, :remove]
version '' #application version (if empty, default: latest)
binary_path '' #application path (if empty, default: /usr/local/bin/helm)
path '' #application path (if empty, default: /usr/local/bin)
end

minikube 'install minikube' do
action [:install, :run, :remove]
version '' #application version (if empty, default: latest)
path '' #application path (if empty, default: /usr/local/bin)
k8s_version '' #kubernetes_version (if empty, default: latest)
network_plugin '' #network plugin use in minikube
bootstrapper '' #bootstrapper use in minikube
vm_driver '' #vm driver use in minikube (if empty, default: none)
end
```

Expand Down Expand Up @@ -85,6 +112,7 @@ end
- [gcloud](#gcloud): install or remove `google-cloud-sdk`.
- [kubectl](#kubectl): install or remove `kubectl`.
- [helm](#helm): install or remove `helm`.
- [minikube](#minikube): install and run or remove `minikube`.

## Resources detail
## gcloud
Expand All @@ -99,7 +127,7 @@ Install `gcloud` with default version:
gcloud 'install default gcloud' do
action :install
version ''
binary_path ''
path ''
end
```

Expand All @@ -109,7 +137,7 @@ Install `gcloud` with specific version:
gcloud 'install specific gcloud version' do
action :install
version '164.0.0'
binary_path ''
path ''
end
```

Expand All @@ -125,7 +153,7 @@ end

- `action` - `:install` to install `gcloud`, `:remove` to uninstall `gcloud`.
- `version` - The desired version of `gcloud`.
- `binary_path` - Application path (if empty, default:/usr/local/bin/gcloud)
- `path` - Application path (if empty, default:/usr/local/bin).

## kubectl

Expand All @@ -139,7 +167,7 @@ Install `kubectl` with default version:
kubectl 'install default kubectl' do
action :install
version ''
binary_path ''
path ''
end
```

Expand All @@ -149,7 +177,7 @@ Install `kubectl` with specific version:
kubectl 'install specific kubectl version' do
action :install
version 'v1.7.0'
binary_path ''
path ''
end
```

Expand All @@ -164,7 +192,7 @@ end
### Properties
- `action` - `:install` to install `kubectl`, `:remove` to uninstall `kubectl`.
- `version` - The desired version of `kubectl`.
- `binary_path` - Application path (if empty, default:/usr/local/bin/kubectl)
- `path` - Application path (if empty, default:/usr/local/bin).

## helm

Expand All @@ -178,7 +206,7 @@ Install `helm` with default version:
helm 'install default helm' do
action :install
version ''
binary_path ''
path ''
end
```

Expand All @@ -188,7 +216,7 @@ Install `helm` with specific version:
helm 'install specific helm version' do
action :install
version 'v2.4.2'
binary_path ''
path ''
end
```

Expand All @@ -203,7 +231,44 @@ end
### Properties
- `action` - `:install` to install `helm`, `:remove` to uninstall `helm`.
- `version` - The desired version of `helm`.
- `binary_path` - Application path (if empty, default:/usr/local/bin/helm)
- `path` - Application path (if empty, default:/usr/local/bin).

## minikube

The `minikube` resource auto-install and run or auto-remove `minikube` with the provider resolution system.

### Example

Install and run `minikube`:

```ruby
minikube 'install minikube' do
action [:install, :run]
version 'v0.25.2' #application version (if empty, default: latest)
path '' #application path (if empty, default: /usr/local/bin)
k8s_version '' #kubernetes_version (if empty, default: latest)
network_plugin 'cni' #network plugin use in minikube
bootstrapper 'kubeadm' #bootstrapper use in minikube
vm_driver 'none' #vm driver use in minikube (if empty, default: none)
end
```

Remove `minikube`:

```ruby
minikube 'remove minikube' do
action :remove
end
```

### Properties
- `action` - `:install` to install `minikube`, `:remove` to uninstall `minikube`.
- `version` - The desired version of `minikube`.
- `k8s_version` - The desired version of `kubernetes resource`.
- `path` - Application path (if empty, default:/usr/local/bin).
- `network_plugin` - Network plugin.
- `bootstrapper` - Bootstrapper.
- `vm_driver` - Vm driver (if empty, default:none).

## See more:

Expand Down
Loading

0 comments on commit 1e00ccc

Please sign in to comment.