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

Fix #350: Add support of 'install-cli' command for kubernetes #369

Merged
merged 6 commits into from
Aug 11, 2016
Merged

Fix #350: Add support of 'install-cli' command for kubernetes #369

merged 6 commits into from
Aug 11, 2016

Conversation

brgnepal
Copy link
Contributor

Fix #350

Also includes:

  • kubernetes install-cli support for CDK
  • Vagrantfile configuration support for kubernetes, i.e config.servicemanager.services = 'kubernetes
  • Unit tests for install-cli for kubernetes
  • Acceptance tests for install-cli for kubernetes

For quick test at local one can use bundle exec rake test rubocop features.

My logs:

➜  vagrant-service-manager git:(fix-350) ✗ bundle exec rake test rubocop features
Run options: --seed 11468

# Running:

.....................................

Finished in 14.060475s, 2.6315 runs/s, 5.6897 assertions/s.

37 runs, 80 assertions, 0 failures, 0 errors, 0 skips
Running RuboCop...
Inspecting 46 files
..............................................

46 files inspected, no offenses detected
\Using existing ADB box (version 2.2.2) in /home/budhram/redhat/vagrant-service-manager/.boxes
|/home/budhram/.rvm/rubies/ruby-2.1.2/bin/ruby -S bundle exec cucumber
Using the default and html profiles...
---------------...............---------------.-------------------------------------------------------------------------------.........................-------------------------.-----------------------------------...........-----------.----------................--------------..........-------------------------------------------------------------...................................-----------------------------------.----------------------------------

24 scenarios (18 skipped, 6 passed)
450 steps (334 skipped, 116 passed)
13m8.380s

describe ADBKubernetesBinaryHandler do
before do
@machine = fake_machine
@options = { type: :kubernetes, '--cli-version' => '1.2.0' } # 1.2.0 is available in CDK/ADB VM
Copy link
Contributor

Choose a reason for hiding this comment

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

Should 1.2.0 be hardcoded here? I believe this information is somewhere else too. I am cool with having an issue opened that notes we need to re-factor this, it appropriate so as to not hold this PR up.

Copy link
Contributor Author

@brgnepal brgnepal Aug 10, 2016

Choose a reason for hiding this comment

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

@bexelbie I think we can manage it well with using locale based or some single configuration based file.

I would like to make it part of refactoring as it should be done across all unit tests then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool - do you mind opening an issue on it so we don't lose it or your thoughts that you have right now? This should not block this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bexelbie Created issue #370 to track it.

@bexelbie
Copy link
Contributor

I've left two comments inline that can be turned into issues and should not block this PR.

However, I don't see the code that creates the config file for kubectl as referenced in https://gist.github.com/praveenkumar/90704a42fe857e1146f3dae2fcae69ef

Am I missing it?

@bexelbie
Copy link
Contributor

@budhrg you mentioned in IRC that kube config creation is part of a separate PR. Where is that PR? I believe this code needs to be dependent on kubectl working once downloaded/installed.

@brgnepal
Copy link
Contributor Author

@bexelbie It is not dependent on the other PR since its an individual feature in itself.

@bexelbie
Copy link
Contributor

@budhrg I agree it is not dependent in a technical sense. However, from a user perspective we either need to tell them how to build their own config file in documentation or we need to add the code that generates the config and installs it for them. I am suggesting the dependency is usability based.

@brgnepal
Copy link
Contributor Author

@bexelbie , @navidshaikh : I have updated the PR with another commit to configure kube config and showing its path through env kubernetes.

Note: To verify this patch, one need to use this patched box.

User workflow would be :

  • vagrant up. It will create a kubeconfig file in ~/.vagrant.d/data/service-manager/kubeconfig path containing required details like token and server ip
  • Get env details as:
eval "$(vagrant service-manager env kubernetes)"
  • Install kubectl as
eval "$(VAGRANT_NO_COLOR=1 vagrant service-manager install-cli kubernetes | tr -d '\r')"
  • Use kubectl as
kubectl version

Below is my end-to-end kubernetes workflow logs

Click Here

$ cat Vagrantfile
- Vagrantfile 
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
    config.vm.box = 'adb-patched-build'   # box downloaded from above mentioned patched box
    config.registration.skip = true
    config.servicemanager.services = 'kubernetes'
end

$ vagrant service-manager env kubernetes
# kubernetes env:
# Set the following environment variables to enable access to the
# kubernetes server running inside of the vagrant virtual machine:
export KUBECONFIG=/home/budhram/.vagrant.d/data/service-manager/kubeconfig

# run following command to configure your shell:
# eval "$(vagrant service-manager env kubernetes)"

$ export KUBECONFIG=/home/budhram/.vagrant.d/data/service-manager/kubeconfig

$ vagrant service-manager install-cli kubernetes
# Binary now available at /home/budhram/.vagrant.d/data/service-manager/bin/kubernetes/1.2.0/kubectl
# run binary as:
# kubectl <command>
export PATH=/home/budhram/.vagrant.d/data/service-manager/bin/kubernetes/1.2.0:$PATH

# run following command to configure your shell:
# eval "$(VAGRANT_NO_COLOR=1 vagrant service-manager install-cli kubernetes | tr -d '\r')"


$ export PATH=/home/budhram/.vagrant.d/data/service-manager/bin/kubernetes/1.2.0:$PATH

$ kubectl get nodes
NAME        STATUS    AGE
127.0.0.1   Ready     6m


$ vagrant service-manager env --script-readable                                                         
DOCKER_HOST=tcp://172.28.128.3:2376
DOCKER_CERT_PATH='/home/budhram/redhat/vagrant-service-manager/.vagrant/machines/default/virtualbox/docker'
DOCKER_TLS_VERIFY=1
DOCKER_API_VERSION=1.22
KUBECONFIG=/home/budhram/.vagrant.d/data/service-manager/kubeconfig

* generate kube's config as part of vagrant up process
* updated config validation to ensure only one of
  openshift and kubernetes service is running
* added acceptance test for kubernetes service(ADB/CDK)
* updated env-command to reflect kubernetes env help
@brgnepal
Copy link
Contributor Author

retest this please

@bexelbie
Copy link
Contributor

The code visually reviews well. I do not have time to test it today, unfortunately. @navidshaikh @tkral or @praveenkumar can you get to it today/your tomorrow morning?

@praveenkumar
Copy link

praveenkumar commented Aug 11, 2016

@budhrg I tested with latest CDK and kubeconf generated as expected and also binary was installed without any issue. LGTM

Let's wait for @navidshaikh test.

* Also excluded plugin_util file from rubocop check
@brgnepal
Copy link
Contributor Author

Working in Windows 10 too.

@navidshaikh
Copy link
Collaborator

Working for Mac and Linux too.

@navidshaikh
Copy link
Collaborator

LGTM

@praveenkumar
Copy link

praveenkumar commented Aug 11, 2016

@navidshaikh / @bexelbie Can you merge it if that is working as expected?

@brgnepal brgnepal merged commit eb1245c into projectatomic:master Aug 11, 2016
@brgnepal brgnepal deleted the fix-350 branch August 12, 2016 11:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support of 'install-cli' command for kubernetes
4 participants