Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0eca200
Initial checkin
srgoni Nov 20, 2018
5384721
Added source code
srgoni Nov 20, 2018
adfca79
Added godep list
srgoni Nov 20, 2018
66fca47
Added vendored dependencies
srgoni Nov 20, 2018
0143449
Added Cloudstack provider sources from Kubernetes
srgoni Nov 20, 2018
18ebd3f
change createLoadBalancerRule to create corresponding firewall rules
joschi36 Nov 20, 2018
65b6c7f
add regex which replaces invalid chars in service offering
joschi36 Nov 20, 2018
2621e50
add dockerfile
joschi36 Nov 20, 2018
3ca5e41
Changed makefile to do a static build
srgoni Dec 10, 2018
f6551e0
Update readme with more build instructions
srgoni Dec 10, 2018
0b76e88
Formatting fix
srgoni Dec 10, 2018
d84b9ee
Notify Docker Hub
joschi36 Dec 10, 2018
c5073d6
Added ref to docker hub
srgoni Dec 10, 2018
97a0cd0
Added simpler direct Docker command line
srgoni Dec 10, 2018
eccb6ca
Added more badges
srgoni Dec 10, 2018
93c53b7
Fixed badge L&F
srgoni Dec 10, 2018
22f625a
Added badge links
srgoni Dec 10, 2018
4b9fd2a
add kubernetes documentation
joschi36 Dec 10, 2018
57629ed
Merge branch 'master' of github.com:swisstxt/cloudstack-cloud-control…
joschi36 Dec 10, 2018
e477e08
change to rel url
joschi36 Dec 10, 2018
f34a58a
Updated Cloudstack library dependency
onitake Feb 1, 2019
f36c5e8
Implemented proxy protocol support via annotation. Fixes #1
onitake Feb 1, 2019
fc54754
Clarified annotatiom comment and added missing proto parameter
onitake Feb 1, 2019
0bf87e4
Added protocol documentation
onitake Feb 1, 2019
b13b4a3
Release 0.0.2
onitake Feb 1, 2019
1cc3405
Migrated from godep to gomod
onitake Feb 1, 2019
750b310
Build in module mode + vendor to avoid downloads and unstable depende…
srgoni Feb 6, 2019
7131210
Added documentation about differences from the old cloud provider
srgoni Feb 6, 2019
207225c
Added Go 1.11 requirement
srgoni Feb 7, 2019
d0d4370
Improved explanation about loadbalancer rules and added hint about re…
srgoni Feb 13, 2019
585b52a
Fixed readme error
srgoni Feb 13, 2019
8ff9708
Update dependencies to k8s 1.14-alpha
srgoni Feb 13, 2019
d358f6f
logs package is now in a different module
srgoni Feb 13, 2019
acbf3d5
Added makefile logic to auto-derive build version from tag
srgoni Feb 13, 2019
bebdb7e
Added more docs about node labels and how to start kubelet
srgoni Feb 15, 2019
2467c25
Removed metadata code that only worked in kubelet
srgoni Feb 6, 2019
fd44810
Added back old dependencies due to legacy k8s cloud provider code
srgoni Feb 15, 2019
0796c96
Merge pull request #3 from swisstxt/feature/metadata
onitake Feb 15, 2019
ed4c118
Backported 65b6c7fa95137022c0d51bb274a82bdebb9009e4 to API-only code
srgoni Feb 15, 2019
1a5c9b6
Improved documentation
srgoni Mar 1, 2019
69e2cf9
Reformatted documentation and moved migration guide towards bottom
srgoni Jun 11, 2019
c11bca6
Merge branch 'master' into transfer
onitake Aug 2, 2019
be437b0
Merged and cleaned readme
onitake Aug 2, 2019
fc8fcba
Removed duplicated license (it's still Apache 2.0)
onitake Aug 2, 2019
bdf256c
Changed docker hub link
onitake Aug 2, 2019
ce3bd88
Removed all vendored dependencies
onitake Aug 6, 2019
3c4cf91
[WIP] Cleaned up dependencies and updated to k8s 1.15.2
onitake Aug 6, 2019
89a6c6c
Added overrides for transitive dependencies
onitake Aug 13, 2019
df8a1f1
Added k8s 1.15.2 dep. Removed explicit versions from direct deps, ove…
onitake Aug 13, 2019
9cd71ed
Added back vendored dependencies
onitake Aug 13, 2019
c0b2b3e
Fixed util/flag dependency
onitake Aug 13, 2019
3d5a27d
Improve documentation on k8s deployment
onitake Aug 14, 2019
5702cba
update deployment to be conformant with normal kubernetes installation
joschi36 Aug 14, 2019
bb161fe
Rewrote licensing paragraph in readme
onitake Aug 14, 2019
a54d0a2
Require Go 1.12
srgoni Aug 15, 2019
d3d86e5
Improved container build process and fixed some old repo references
srgoni Aug 15, 2019
73bdea5
Replaced the remaining repo references with the new code home
srgoni Aug 15, 2019
0da7309
bump xanzy/go-cloudstack to v2.7.0
joschi36 Sep 13, 2019
47340d2
Replaced license terms and copyright notices as required by the ASF
onitake Sep 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/cloudstack-ccm

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.12 as builder
COPY . /go/src/github.com/apache/cloudstack-kubernetes-provider
WORKDIR /go/src/github.com/apache/cloudstack-kubernetes-provider
RUN make clean && CGO_ENABLED=0 GOOS=linux make

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/apache/cloudstack-kubernetes-provider .
CMD ["./cloudstack-ccm", "--cloud-provider", "external-cloudstack"]
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_COMMIT_SHORT=$(shell git rev-parse --short HEAD)
GIT_TAG=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo v0.0.0)
GIT_IS_TAG=$(shell git describe --exact-match --abbrev=0 --tags 2>/dev/null || echo NOT_A_TAG)
ifeq (${GIT_IS_TAG},NOT_A_TAG)
GIT_VERSION?=$(patsubst v%,%,${GIT_TAG})-master+${GIT_COMMIT}
else
GIT_VERSION?=$(patsubst v%,%,${GIT_TAG})
endif
LDFLAGS="-X github.com/apache/cloudstack-kubernetes-provider/vendor/k8s.io/kubernetes/pkg/version.gitVersion=${GIT_VERSION} -X github.com/apache/cloudstack-kubernetes-provider/vendor/k8s.io/kubernetes/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/apache/cloudstack-kubernetes-provider/vendor/k8s.io/kubernetes/pkg/version.buildDate=${BUILD_DATE}"
export CGO_ENABLED=0
export GO111MODULE=on

CMD_SRC=\
cmd/cloudstack-ccm/main.go

.PHONY: all clean docker

all: cloudstack-ccm

clean:
rm -f cloudstack-ccm

cloudstack-ccm: ${CMD_SRC}
go build -mod vendor -ldflags ${LDFLAGS} -o $@ $^

docker:
docker build . -t apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT}
docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} apache/cloudstack-kubernetes-provider:latest
ifneq (${GIT_IS_TAG},NOT_A_TAG)
docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} apache/cloudstack-kubernetes-provider:${GIT_TAG}
endif
28 changes: 28 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Apache CloudStack Kubernetes Provider
Copyright 2019 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).


The vendor/ subdirectory contains external dependencies of the software,
which may bear a different copyright and/or a different license.
Plese refer to the LICENSE file in each project for the respective terms.


The software is based on previous work, which bears the following license:

Copyright 2016 The Kubernetes Authors.
Copyright 2018 SWISS TXT AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
152 changes: 146 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,150 @@
# CloudStack Kubernetes Provider

Old provider in v1.15:
https://github.com/kubernetes/kubernetes/tree/release-1.15/pkg/cloudprovider/providers/cloudstack
[![](https://img.shields.io/github/release/apache/cloudstack-kubernetes-provider.svg?style=flat-square "Release")](https://github.com/apache/cloudstack-kubernetes-provider/releases)
[![](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square "Apache 2.0 license")](/LICENSE-2.0)
[![](https://img.shields.io/badge/language-Go-%235adaff.svg?style=flat-square "Go language")](https://golang.org)
[![](https://img.shields.io/docker/build/apache/cloudstack-kubernetes-provider.svg?style=flat-square "Docker build status")](https://hub.docker.com/r/apache/cloudstack-kubernetes-provider/)

A Cloud Controller Manager to facilitate Kubernetes deployments on Cloudstack.

Based on the old Cloudstack provider in Kubernetes that will be removed soon.

Refer:
https://github.com/kubernetes/enhancements/issues/672
https://github.com/kubernetes/enhancements/issues/88
https://github.com/swisstxt/cloudstack-cloud-controller-manager
https://github.com/tsuru/custom-cloudstack-ccm
* https://github.com/kubernetes/kubernetes/tree/release-1.15/pkg/cloudprovider/providers/cloudstack
* https://github.com/kubernetes/enhancements/issues/672
* https://github.com/kubernetes/enhancements/issues/88

## Deployment

### Kubernetes

Prebuilt containers are posted on [Docker Hub](https://hub.docker.com/r/apache/cloudstack-kubernetes-provider).

The cloud controller is intended to be deployed as a daemon set, with on instance running on each node.

To configure API access to your CloudStack management server, you need to create a secret containing a `cloudstack.ini`
that is suitable for your environment.

`cloudstack.ini` should look like this:
```ini
[Global]
api-url = <CloudStack API URL>
api-key = <CloudStack API Key>
secret-key = <CloudStack API Secret>
project-id = <CloudStack Project UUID (optional)>
zone = <CloudStack Zone Name (optional)>
ssl-no-verify = <Disable SSL certificate validation: true or false (optional)>
```

The access token needs to be able to fetch VM information and deploy load balancers in the project or domain where the nodes reside.

To create the secret, use the following command:
```bash
kubectl create secret generic cloudstack-secret --from-file=cloudstack.ini
```

You can then use the provided example [deployment.yaml](/deployment.yaml) to deploy the controller:
```bash
kubectl apply -f deployment.yaml
```

### Protocols

This CCM supports TCP, UDP and [TCP-Proxy](https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt) LoadBalancer deployments.

For UDP and Proxy Protocol support, CloudStack 4.6 or later is required.

Since kube-proxy does not support the Proxy Protocol or UDP, you should connect this directly to pods, for example by deploying a DaemonSet and setting `hostNetwork: true`.
The service running in the pod must support the protocol.

See [service.yaml](/service.yaml) for an example Service deployment and part of a suitable configuration for an ingress controller.

### Node Labels

:warning: **The node name must match the host name, so the controller can fetch and assign metadata from CloudStack.**

It is recommended to launch `kubelet` with the following parameter:

```
--register-with-taints=node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
```

This will treat the node as 'uninitialized' and cause the CCM to apply metadata labels from CloudStack automatically.

Supported labels are:
* kubernetes.io/hostname (= the instance name)
* beta.kubernetes.io/instance-type (= the compute offering)
* failure-domain.beta.kubernetes.io/zone (= the zone)
* failure-domain.beta.kubernetes.io/region (also = the zone)

It is also possible to trigger this process manually by issuing the following command:

```
kubectl taint nodes <my-node-without-labels> node.cloudprovider.kubernetes.io/uninitialized=true:NoSchedule
```

## Migration Guide

There are several notable differences to the old Kubernetes CloudStack cloud provider that need to be taken into
account when migrating from the old cloud provider to the standalone controller.

### Load Balancer

Load balancer rule names now include the protocol in addition to the LB name and service port.
This was added to distinguish tcp, udp and tcp-proxy services operating on the same port.
Without this change, it would not be possible to map a service that runs on both TCP and UDP port 8000, for example.

:warning: **If you have existing rules, remove them before the migration, and add them back afterwards.**

If you don't do this, you will end up with duplicate rules for the same service, which won't work.

### Metadata

Since the controller is now intended to be run inside a pod and not on the node, it will not be able to fetch metadata from the Virtual Router's DHCP server.

Instead, it first obtains the name of the node from Kubernetes, then fetches information from the CloudStack API.

## Development

### Building

Go 1.12 is required to build cloudstack-ccm.

It is recommended to build with Go module support, but dependencies are also vendored.

To build the controller with correct versioning, some build flags need to be passed.
A Makefile is provided that sets these build flags to values obtained from git.

```bash
go get github.com/apache/cloudstack-kubernetes-provider
cd ${GOPATH}/src/github.com/apache/cloudstack-kubernetes-provider
make
```

To build the cloudstack-cloud-controller-manager container, please use the provided Dockerfile.
The Makefile will also with that and properly tag the resulting container.

```bash
make docker
```

### Testing

You need a local instance of the CloudStack Management Server or a 'real' one to connect to.
The CCM supports the same cloudstack.ini configuration file format used by [the cs tool](https://github.com/exoscale/cs),
so you can simply point it to that.

```bash
./cloudstack-ccm --cloud-provider external-cloudstack --cloud-config ~/.cloudstack.ini --master k8s-apiserver
```

Replace k8s-apiserver with the host name of your Kubernetes development clusters's API server.

If you don't have a 'real' CloudStack installation, you can also launch a local [simulator instance](https://hub.docker.com/r/cloudstack/simulator) instead. This is very useful for dry-run testing.

## Copyright

Copyright 2019 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Loading