Cent OS7に ksonnetとGo言語をインストール
CentOSにksonnet(ks)をインストールするには、Goで手動ビルドする必要があるようで、まずはGoをインストール
Go言語インストール
任意の場所でwgetでバイナリをダウンロードして展開するのみ
最新版は、以下でチェック
https://golang.org/dl/
wget https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz
tar vzfx go1.11.2.linux-amd64.tar.gz
/usr/local
あたりに格納しておく
sudo mv go /usr/local/
PATHも通しておく
vi ${HOME}/.bash_profile
以下を追加
export GOPATH="$HOME/go"
export PATH="/usr/local/go/bin:$PATH"
GOPATHは、go getなどのコマンドで利用する作業用フォルダ的なものらしい
source .bash_profile
コマンドで再読み込みすると、goのインストール完了
$ go
Go is a tool for managing Go source code.
Usage:
go <command> [arguments]
The commands are:
bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
env print Go environment information
fix update packages to use new APIs
fmt gofmt (reformat) package sources
generate generate Go files by processing source
get download and install packages and dependencies
install compile and install packages and dependencies
list list packages or modules
mod module maintenance
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet report likely mistakes in packages
Use "go help <command>" for more information about a command.
Additional help topics:
buildmode build modes
c calling between Go and C
cache build and test caching
environment environment variables
filetype file types
go.mod the go.mod file
gopath GOPATH environment variable
gopath-get legacy GOPATH go get
goproxy module proxy protocol
importpath import path syntax
modules modules, module versions, and more
module-get module-aware go get
packages package lists and patterns
testflag testing flags
testfunc testing functions
Use "go help <topic>" for more information about that topic.
GOPATHはクセがあり、GOROOTと同じにすると、go getコマンド実行時に下記のようなエラーを吐く
package github.com/ksonnet/ksonnet: cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'
例えば、wgetして展開したgoディレクトリをそのままGOPATHにしたら上記となった。どうやらその直下がGOROOT。
なので展開ファイルはそのまま/usr/local/にmvし、別途${HOME}/goをGOPATHに設定したところ、問題は解消した。
ksonnetインストール
ksonnetとは?
KubernetesでYamlではなくCLIで簡単にアプリケーションデプロイができるようにするための仕組み。
類似のものにHelmがある。
CentOSのyumのように、kubernetesクラスタを1つのOSと見立てて、installコマンドで簡単にパッケージ管理をしようというもの。
yamlを用意してkubectl create -f xxx.yaml
する代わりに、ks pkg install xxx
だけでインストールができるようになる。
参考)
https://github.com/ksonnet/ksonnet/blob/master/docs/build-install.md
ksonnetファイルを取得
go get github.com/ksonnet/ksonnet
go getで$GOPATHにファイル一式がDLされるのでビルドする
cd $GOPATH/src/github.com/ksonnet/ksonnet
make install
t3.smallインスタンス相当で20分ほどかかりました。
$GOPATH/bin/ks
が生成されるので、/usr/local/go/bin/
あたりにコピー。
ksonnetインストール完了
$ ks
You can use the `ks` commands to write, share, and deploy your Kubernetes
application configuration to remote clusters.
----
Usage:
ks [flags]
ks [command]
Available Commands:
apply Apply local Kubernetes manifests (components) to remote clusters
component Manage ksonnet components
delete Remove component-specified Kubernetes resources from remote clusters
diff Compare manifests, based on environment or location (local or remote)
env Manage ksonnet environments
generate Use the specified prototype to generate a component manifest
help Help about any command
import Import manifest
init Initialize a ksonnet application
module Manage ksonnet modules
param Manage ksonnet parameters for components and environments
pkg Manage packages and dependencies for the current ksonnet application
prototype Instantiate, inspect, and get examples for ksonnet prototypes
registry Manage registries for current project
show Show expanded manifests for a specific environment.
upgrade Upgrade ks configuration
validate Check generated component manifests against the server's API
version Print version information for this ksonnet binary
Flags:
--dir string Ksonnet application root to use; Defaults to CWD (default "/usr/local/go")
-h, --help help for ks
--tls-skip-verify Skip verification of TLS server certificates
-v, --verbose count Increase verbosity. May be given multiple times.
Use "ks [command] --help" for more information about a command.