Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 07a8e08

Browse files
author
David Chung
authored
RackHD support (#698)
* Setup basic structure * Setup basic structure * Create an interface & mocks for RackHD monorail client Interface and mocks may move into gorackhd project once proven out in this project. * Find compute node to provision * Create README.md * Create LICENSE * Add Login() to monorail client * Switch to SKUs and add auth * Refactor and add workflow options * Exclude build contents, but keep build dir * Add instance destroy support * Switch to Ginkgo tests * Rename some specs * Fixes and clean up * Add label and describe support * Lock node for Infrakit when provisioning * Add spec validation to plugin * Add Vagrant demo to project * Update to latest infrakit spec * new logo create a new logo to have before DockerCon showcase. Also added a small blurb at the beginning to throw some more marketing magic on it. Signed-off-by: Kendrick Coleman <kendrickcoleman@gmail.com> * Remove inadvertently added vagrant files * Update to 2.x RackHD API * Update demo * Improve provisioning, destruction and descriptions * provisioning and destructions are now prevented from nodes with active workflows * descriptions now include node IP addresses as learned from Ohai node catalog * Some cleanup/refactoring TODO: update tests to match * Reorganize files before import into infrakit repo Signed-off-by: David Chung <david.chung@docker.com> * Add vendored sources Signed-off-by: David Chung <david.chung@docker.com> * Code fixes to get rackhd to compile Signed-off-by: David Chung <david.chung@docker.com> * Driver to include rackhd as built-in; disable test temporarily Signed-off-by: David Chung <david.chung@docker.com> * fix lint Signed-off-by: David Chung <david.chung@docker.com>
1 parent eef7750 commit 07a8e08

File tree

583 files changed

+237127
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

583 files changed

+237127
-2
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ coverage.txt
88
.tags
99

1010
# Build binaries
11-
build/
11+
build/*
12+
13+
# Demo files
14+
demo/*
1215

1316
# Vim temporary files.
1417
.*.swp

circle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ machine:
1111
GOPATH: "$HOME/.go_workspace"
1212
WORKDIR: "$GOPATH/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
1313
E2E_CLEANUP: "false"
14-
SKIP_TESTS: "docker,etcd,terraform,flaky"
14+
SKIP_TESTS: "docker,etcd,terraform,rackhd,flaky"
1515
S3_MINIO: "s3bucket"
1616
S3_BUCKET: "s3bucket/infrakit/build/linux-amd64"
1717
S3_BUILD_RELEASE: "infrakit-$CIRCLE_BRANCH.tar.gz"

cmd/infrakit/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
_ "github.com/docker/infrakit/pkg/run/v0/ingress"
5050
_ "github.com/docker/infrakit/pkg/run/v0/kubernetes"
5151
_ "github.com/docker/infrakit/pkg/run/v0/manager"
52+
_ "github.com/docker/infrakit/pkg/run/v0/rackhd"
5253
_ "github.com/docker/infrakit/pkg/run/v0/selector"
5354
_ "github.com/docker/infrakit/pkg/run/v0/simulator"
5455
_ "github.com/docker/infrakit/pkg/run/v0/swarm"
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 {code} by Dell EMC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# REPO
2+
REPO?=github.com/codedellemc/infrakit.rackhd
3+
4+
# Set an output prefix, which is the local directory if not specified
5+
PREFIX?=$(shell pwd -L)
6+
7+
# Used to populate version variable in main package.
8+
VERSION?=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
9+
REVISION?=$(shell git rev-list -1 HEAD)
10+
11+
# Allow turning off function inlining and variable registerization
12+
ifeq (${DISABLE_OPTIMIZATION},true)
13+
GO_GCFLAGS=-gcflags "-N -l"
14+
VERSION:="$(VERSION)-noopt"
15+
endif
16+
17+
.PHONY: clean all fmt vet lint build test containers get-tools
18+
.DEFAULT: all
19+
all: clean fmt vet lint build test
20+
21+
ci: fmt vet lint coverage
22+
23+
AUTHORS: .mailmap .git/HEAD
24+
git log --format='%aN <%aE>' | sort -fu > $@
25+
26+
# Package list
27+
PKGS_AND_MOCKS := $(shell go list ./... | grep -v ^${REPO}/vendor/)
28+
PKGS := $(shell echo $(PKGS_AND_MOCKS) | tr ' ' '\n' | grep -v /mock$)
29+
30+
vet:
31+
@echo "+ $@"
32+
@go vet $(PKGS)
33+
34+
fmt:
35+
@echo "+ $@"
36+
@test -z "$$(gofmt -s -l . 2>&1 | grep -v ^vendor/ | tee /dev/stderr)" || \
37+
(echo >&2 "+ please format Go code with 'gofmt -s', or use 'make fmt-save'" && false)
38+
39+
fmt-save:
40+
@echo "+ $@"
41+
@gofmt -s -l . 2>&1 | grep -v ^vendor/ | xargs gofmt -s -l -w
42+
43+
lint:
44+
@echo "+ $@"
45+
$(if $(shell which golint || echo ''), , \
46+
$(error Please install golint: `go get -u github.com/golang/lint/golint`))
47+
@test -z "$$(golint ./... 2>&1 | grep -v ^vendor/ | grep -v mock/ | tee /dev/stderr)"
48+
49+
build:
50+
@echo "+ $@"
51+
@go build ${GO_LDFLAGS} $(PKGS)
52+
53+
clean:
54+
@echo "+ $@"
55+
rm -rf build
56+
mkdir -p build
57+
58+
define build_binary
59+
go build -o build/$(1) \
60+
-ldflags "-X github.com/codedellemc/infrakit.rackhd/plugin.Version=$(VERSION) -X github.com/codedellemc/infrakit.rackhd/plugin.Revision=$(REVISION)" $(2)
61+
endef
62+
binaries: clean build-binaries
63+
build-binaries:
64+
@echo "+ $@"
65+
ifneq (,$(findstring .m,$(VERSION)))
66+
@echo "\nWARNING - repository contains uncommitted changes, tagging binaries as dirty\n"
67+
endif
68+
69+
$(call build_binary,infrakit-instance-rackhd,github.com/codedellemc/infrakit.rackhd/plugin/instance/cmd)
70+
71+
72+
install:
73+
@echo "+ $@"
74+
@go install ${GO_LDFLAGS} $(PKGS)
75+
76+
generate:
77+
@echo "+ $@"
78+
@go generate -x $(PKGS_AND_MOCKS)
79+
80+
test:
81+
@echo "+ $@"
82+
@go test -test.short -race -v $(PKGS)
83+
84+
coverage:
85+
@echo "+ $@"
86+
@for pkg in $(PKGS); do \
87+
go test -test.short -coverprofile="../../../$$pkg/coverage.txt" $${pkg} || exit 1; \
88+
done
89+
90+
test-full:
91+
@echo "+ $@"
92+
@go test -race $(PKGS)
93+
94+
get-tools:
95+
@echo "+ $@"
96+
@go get -u \
97+
github.com/golang/lint/golint \
98+
github.com/wfarner/blockcheck \
99+
github.com/rancher/trash
100+
101+
# Current working environment. Set these explicitly if you want to cross-compile
102+
# in the build container (see the build-in-container target):
103+
GOOS?=$(shell go env GOOS)
104+
GOARCH?=$(shell go env GOARCH)
105+
DOCKER_BUILD_FLAGS?=--no-cache --pull
106+
build-in-container:
107+
@echo "+ $@"
108+
@docker build ${DOCKER_BUILD_FLAGS} -t infrakit-build -f ${CURDIR}/dockerfiles/Dockerfile.build .
109+
@docker run --rm \
110+
-e GOOS=${GOOS} -e GOARCCH=${GOARCH} -e DOCKER_CLIENT_VERSION=${DOCKER_CLIENT_VERSION} \
111+
-v ${CURDIR}/build:/go/src/${REPO}/build \
112+
infrakit-build
113+
114+
# For packaging as Docker container images. Set the environment variables DOCKER_PUSH, DOCKER_TAG_LATEST
115+
# if also push to remote repo. You must have access to the remote repo.
116+
DOCKER_IMAGE?=infrakit/rackhd
117+
DOCKER_TAG?=dev
118+
build-docker:
119+
@echo "+ $@"
120+
GOOS=linux GOARCH=amd64 make build-in-container
121+
@docker build ${DOCKER_BUILD_FLAGS} \
122+
-t ${DOCKER_IMAGE}:${DOCKER_TAG} \
123+
-f ${CURDIR}/dockerfiles/Dockerfile.bundle .
124+
ifeq (${DOCKER_PUSH},true)
125+
@docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
126+
ifeq (${DOCKER_TAG_LATEST},true)
127+
@docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest
128+
@docker push ${DOCKER_IMAGE}:latest
129+
endif
130+
endif
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# InfraKit.RackHD
2+
3+
**Docker for Private Clouds**
4+
5+
The first and only open source toolkit for creating and managing declarative, self-healing, and platform-agnostic infrastructure in your data center.
6+
7+
8+
[InfraKit](https://github.com/docker/infrakit) plugins for creating and managing resources in [RackHD](https://github.com/RackHD/RackHD).
9+
10+
![logo](img/rackhd-infrakit-logo.png "Logo")
11+
12+
## Instance plugin
13+
14+
An InfraKit instance plugin is provided, which runs RackHD workflows to provision compute nodes.
15+
16+
### Building and running
17+
18+
To build the RackHD Instance plugin, run `make binaries`. The plugin binary will be located at
19+
`./build/infrakit-instance-rackhd`.
20+
21+
### Example
22+
23+
TODO
24+
25+
## Licensing
26+
infrakit.rackhd is freely distributed under the [MIT License](http://codedellemc.github.io/sampledocs/LICENSE "LICENSE"). See LICENSE for details.
27+
28+
##Support
29+
Please file bugs and issues on the Github issues page for this project. This is to help keep track and document everything related to this repo. For general discussions and further support you can join the [{code} by Dell EMC Community slack team](http://community.codedellemc.com/) and join the **#rackhd** channel. The code and documentation are released with no warranties or SLAs and are intended to be supported through a community driven process.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# vim:set ft=ruby
2+
Vagrant.configure("2") do |config|
3+
config.vm.box = "rackhd/rackhd"
4+
config.vm.box_version = "2.1.0"
5+
config.vm.provider "virtualbox" do |v|
6+
v.memory = 4096
7+
v.cpus = 4
8+
v.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
9+
end
10+
11+
config.vm.network "private_network", ip: "172.31.128.1", virtualbox__intnet: "closednet", auto_config: false, nic_type: "82540EM"
12+
config.vm.network "forwarded_port", guest: 8080, host: 9090
13+
config.vm.network "forwarded_port", guest: 5672, host: 9091
14+
config.vm.network "forwarded_port", guest: 9080, host: 9092
15+
config.vm.network "forwarded_port", guest: 8443, host: 9093
16+
config.vm.network "forwarded_port", guest: 7080, host: 6080
17+
18+
# If true, then any SSH connections made will enable agent forwarding.
19+
# Default value: false
20+
21+
config.ssh.forward_agent = true
22+
23+
# Enable admin user
24+
config.vm.provision "shell", inline: <<-EOS
25+
/usr/bin/curl -sk -H "Content-Type: application/json" -X POST https://localhost:8443/api/current/users -d '{"username": "admin", "password": "admin123", "role": "Administrator"}'
26+
if [ ! -f on-tools ]
27+
then
28+
git clone https://github.com/RackHD/on-tools.git
29+
fi
30+
if [ ! -f /var/mirrors/Centos/7.0 ]
31+
then
32+
sudo python ./on-tools/scripts/setup_iso.py /vagrant/CentOS-7-x86_64-DVD-1611.iso /var/mirrors --link /var/renasar
33+
fi
34+
sudo ln -s /var/mirrors/Centos /var/renasar/on-http/static/http/centos
35+
sudo mkdir /var/mirrors/Centos/7.0/os
36+
sudo ln -s /var/mirrors/Centos/7.0 /var/mirors/Centos/7.0/os/x86_64
37+
sudo ln -s /var/mirrors/Centos /var/renasar/on-http/static/http/centos
38+
sudo perl -pi -e 's|monorail-undionly.kpxe|monorail.ipxe|g' /var/renasar/on-dhcp-proxy/lib/message-handler.js
39+
sudo service on-dhcp-proxy restart
40+
EOS
41+
42+
# Install Docker Infrakit
43+
# config.vm.provision "shell",
44+
# env: {
45+
# "GOROOT" => "/home/vagrant/go",
46+
# "GOPATH" => "/home/vagrant/gocode"
47+
# },
48+
# inline: <<-EOS
49+
# mkdir /home/vagrant/go
50+
# mkdir /home/vagrant/gocode
51+
# /usr/bin/apt-get install -y gccgo-go
52+
# go get gofmt
53+
# go get github.com/docker/infrakit
54+
# go get github.com/codedellemc/infrakit.rackhd
55+
# cd infrakit
56+
# make binaries
57+
# build/infrakit-group-default &
58+
# build/infrakit-flavor-vanilla &
59+
# EOS
60+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
vagrant up
2+
3+
if [ ! -f ./CentOS-7-x86_64-DVD-1611.iso ]
4+
then
5+
wget http://mirrors.usc.edu/pub/linux/distributions/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso
6+
fi
7+
8+
export TOKEN=`curl -sk -H "Content-Type: application/json" -X POST -d '{"username": "admin", "password": "admin123"}' https://localhost:9093/login | jq '.["token"]' | sed 's|"||g'`
9+
10+
echo "Create VirtualBox SKU in RackHD"
11+
12+
curl -sk -H "Authorization: JWT $TOKEN" -H "Content-Type: application/json" -X POST -d '{ "name": "VirtualBox", "rules": [ { "path": "dmi.Base Board Information.Product Name", "equals": "VirtualBox" } ] }' https://localhost:9093/api/current/skus
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Properties": {
3+
"Workflow": {
4+
"name": "Graph.InstallCentOS",
5+
"options": {
6+
"install-os": {
7+
"version": "7.0",
8+
"repo": "{{file.server}}/Centos/7.0",
9+
"rootPassword": "root"
10+
}
11+
}
12+
},
13+
"SKUName": "vQuanta D51 SKU"
14+
},
15+
"Tags": {
16+
"Name": "infrakit-example"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"ID": "rackhd-example",
3+
"Properties": {
4+
"Allocation": {
5+
"Size": 1
6+
},
7+
"Instance": {
8+
"Plugin": "rackhd",
9+
"Properties": {
10+
"Workflow": {
11+
"name": "Graph.InstallCentOS",
12+
"options": {
13+
"defaults": {
14+
"version": "7.0",
15+
"rootPassword": "root"
16+
}
17+
}
18+
},
19+
"SKUName": "VirtualBox"
20+
},
21+
"Tags": {
22+
"Name": "infrakit-example"
23+
}
24+
},
25+
"Flavor": {
26+
"Plugin": "flavor-vanilla",
27+
"Init": [
28+
"sudo yum install -y nginx",
29+
"sudo service nginx start"
30+
],
31+
"Properties": {
32+
"Tags": {
33+
"tier": "web",
34+
"project": "infrakit"
35+
}
36+
}
37+
}
38+
}
39+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package instance
2+
3+
import (
4+
"github.com/docker/infrakit/pkg/spi/instance"
5+
"github.com/spf13/pflag"
6+
"github.com/spiegela/gorackhd/monorail"
7+
)
8+
9+
// Options contain parameters required to connect to RackHD
10+
type Options struct {
11+
Endpoint string
12+
Username string
13+
Password string
14+
}
15+
16+
// Builder is a ProvisionerBuilder that creates a RackHD instance provisioner
17+
type Builder struct {
18+
options Options
19+
}
20+
21+
// Flags returns the flags required.
22+
func (b *Builder) Flags() *pflag.FlagSet {
23+
flags := pflag.NewFlagSet("rackhd", pflag.PanicOnError)
24+
flags.StringVar(&b.options.Endpoint, "endpoint", "http://localhost:9090", "RackHD API Endpoint")
25+
flags.StringVar(&b.options.Username, "username", "admin", "RackHD Username")
26+
flags.StringVar(&b.options.Password, "password", "admin123", "RackHD Password")
27+
return flags
28+
}
29+
30+
// BuildInstancePlugin creates an instance Provisioner configured with the Flags.
31+
func (b *Builder) BuildInstancePlugin() (instance.Plugin, error) {
32+
mc := monorail.New(b.options.Endpoint)
33+
return NewInstancePlugin(mc, b.options.Username, b.options.Password), nil
34+
}

0 commit comments

Comments
 (0)