Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synch repo cluster-api-provider-powervs with machine-api-provider-powervs #1

Merged
merged 74 commits into from Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
f091abb
Initial commit
jthiatt Jun 1, 2021
e6fef06
Create OWNERS
mkumatag Jun 11, 2021
3554fa4
Initial commit
mkumatag Jun 11, 2021
5126db7
update owners
mkumatag Jun 11, 2021
7c771d4
Merge pull request #1 from mkumatag/main
openshift-merge-robot Jun 14, 2021
66ed9b6
Add .gitignore file
mkumatag Jun 17, 2021
e938593
Merge pull request #2 from mkumatag/git_ignore
openshift-merge-robot Jun 17, 2021
aecd477
Fix dockerfile
mkumatag Jun 18, 2021
5c2c14f
Merge pull request #3 from mkumatag/fix_dockerfile
openshift-merge-robot Jun 18, 2021
5024919
PowerVSMachineProviderConfig variable name changes and go mod vendor …
Karthik-K-N Jun 21, 2021
a5ccc9c
Merge pull request #4 from Karthik-K-N/variable_name_changes
openshift-merge-robot Jun 21, 2021
9a5cdcf
build_root configuration
mkumatag Jun 24, 2021
9352384
Merge pull request #5 from mkumatag/build_root
openshift-merge-robot Jun 24, 2021
026967b
Fix for golint errors
Karthik-K-N Jun 24, 2021
18c1270
Merge pull request #7 from Karthik-K-N/fix-go-lint
openshift-merge-robot Jun 24, 2021
5329599
Fix lint and fmt issues
mkumatag Jun 24, 2021
9eee608
Merge pull request #8 from mkumatag/fix_lint
openshift-merge-robot Jun 24, 2021
2a5ab0c
Changes for making debug mode optional while creating Power VS client
Karthik-K-N Jun 30, 2021
e384387
Merge pull request #11 from Karthik-K-N/debug-feature
openshift-merge-robot Jul 1, 2021
7342a8d
Added unit test cases for Power VS provider
Karthik-K-N Jun 23, 2021
086dba1
Merge pull request #9 from Karthik-K-N/unit-test-cases
openshift-merge-robot Jul 1, 2021
9ca378c
Update power-go-client to v1.0.72 version
mkumatag Jul 5, 2021
56a9503
Merge pull request #13 from mkumatag/update_power_client
openshift-merge-robot Jul 6, 2021
9e3f06d
Rename IBMCLOUD_API_KEY to ibmcloud_api_key
mkumatag Jul 26, 2021
0b67886
Merge pull request #14 from mkumatag/change_key_name
openshift-merge-robot Jul 26, 2021
95e4ae8
Update the base and builder to the latest level
mkumatag Jul 27, 2021
9642138
Merge pull request #15 from mkumatag/update_dockerfile
openshift-merge-robot Jul 27, 2021
3e1125c
Remove termination-handler
mkumatag Jul 27, 2021
8113bf3
Merge pull request #16 from mkumatag/remove-termination-handler
openshift-merge-robot Jul 27, 2021
1b27a66
Upgrade to v1 crds
mkumatag Jul 28, 2021
5a9967d
Merge pull request #18 from mkumatag/upgrade_to_v1
openshift-ci[bot] Aug 4, 2021
3f6d26a
Update to golang 1.16
mkumatag Aug 4, 2021
9423a0d
Rename the secret name for the credentials
mkumatag Aug 6, 2021
88bace4
Merge pull request #19 from mkumatag/update-golang
openshift-ci[bot] Aug 6, 2021
8d6017f
Merge pull request #20 from mkumatag/rename_secret
openshift-ci[bot] Aug 6, 2021
ac44f1f
Rename providerid to match the patter with vpc provider
mkumatag Aug 23, 2021
9865614
Merge pull request #21 from mkumatag/provider_id
openshift-merge-robot Aug 23, 2021
81e0c5c
Refine the spec
mkumatag Sep 21, 2021
d899ffb
Merge pull request #25 from mkumatag/refine
openshift-merge-robot Sep 21, 2021
3659473
Populate the NodeInternalDNS for the machine
mkumatag Sep 28, 2021
8eb5ebc
Merge pull request #27 from mkumatag/add_dns
openshift-merge-robot Sep 28, 2021
4155cbc
Add bugzilla information
mkumatag Oct 11, 2021
5f9aca2
Merge pull request #28 from mkumatag/add_bz
openshift-merge-robot Oct 11, 2021
236b028
disable cgo for go build
mkumatag Oct 12, 2021
152fe9a
Merge pull request #29 from mkumatag/fix_build
openshift-merge-robot Oct 12, 2021
359650c
Updating ose-powervs-machine-controllers images to be consistent with…
Oct 12, 2021
3e9cd98
Merge pull request #30 from openshift-bot/art-consistency-openshift-4…
openshift-merge-robot Oct 12, 2021
c25bb3a
Changes to add debug mode flag
Karthik-K-N Sep 27, 2021
6c9314f
Merge pull request #26 from Karthik-K-N/enable-debug-mode
openshift-merge-robot Oct 14, 2021
8eb7b52
vendor files
mkumatag Nov 9, 2021
4639dce
go mod updates
mkumatag Nov 9, 2021
de18624
update the imports
mkumatag Nov 9, 2021
26e7bec
autogenerate the mock clients
mkumatag Nov 9, 2021
bc8a5c9
workaround the mocks with AnyTimes()
mkumatag Nov 9, 2021
7c48308
Merge pull request #33 from mkumatag/deps_cleanup
openshift-merge-robot Nov 9, 2021
68a13a1
Updating ose-powervs-machine-controllers images to be consistent with…
Nov 9, 2021
ea7610e
Merge pull request #35 from openshift-bot/art-consistency-openshift-4…
openshift-merge-robot Nov 10, 2021
d4be89b
Bump golang version to 1.17
mkumatag Nov 10, 2021
f3b2d0a
Merge pull request #36 from mkumatag/bump_go_version
openshift-merge-robot Nov 10, 2021
5ff20c6
Use podman or docker
mkumatag Nov 10, 2021
58f8170
Merge pull request #37 from mkumatag/podman
openshift-merge-robot Nov 10, 2021
1064d35
Add support for customendpoints
Karthik-K-N Oct 14, 2021
7a02983
Update client minimal to read custom service endpoints
Karthik-K-N Nov 15, 2021
dbb96b3
Merge pull request #31 from Karthik-K-N/custom-service-endpoint
openshift-merge-robot Nov 30, 2021
dc84795
Update MAO and openshift/api dependency
mkumatag Nov 30, 2021
a05198d
Merge pull request #39 from mkumatag/update_dep
openshift-merge-robot Nov 30, 2021
2e8e817
Updated README file
Karthik-K-N Jan 5, 2022
4be1f7f
Merge pull request #40 from Karthik-K-N/updateReadME
openshift-merge-robot Jan 5, 2022
7b874ae
Updated power go client
Karthik-K-N Jan 11, 2022
51109fb
Merge pull request #41 from Karthik-K-N/update-power-goclient
openshift-merge-robot Jan 11, 2022
8d60a9b
Updated kubernetes version to 1.23
Karthik-K-N Jan 12, 2022
1b59284
Merge pull request #42 from Karthik-K-N/update-k8-version
openshift-merge-robot Jan 12, 2022
8372695
Merge cluster-api-powervs to machine-api-powervs
Karthik-K-N Jan 28, 2022
71ef740
Updated README file
Karthik-K-N Jan 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
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.
4 changes: 4 additions & 0 deletions .ci-operator.yaml
@@ -0,0 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: rhel-8-release-golang-1.17-openshift-4.10
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -11,5 +11,4 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
bin/
9 changes: 9 additions & 0 deletions Dockerfile
@@ -0,0 +1,9 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.16 AS builder
WORKDIR /go/src/github.com/openshift/cluster-api-provider-powervs
COPY . .
# VERSION env gets set in the openshift/release image and refers to the golang version, which interfers with our own
RUN unset VERSION \
&& GOPROXY=off NO_DOCKER=1 GOARCH=ppc64le make build

FROM --platform=ppc64le registry.access.redhat.com/ubi8/ubi:8.4
COPY --from=builder /go/src/github.com/openshift/cluster-api-provider-powervs/bin/machine-controller-manager /
9 changes: 9 additions & 0 deletions Dockerfile.rhel
@@ -0,0 +1,9 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.17-openshift-4.10 AS builder
WORKDIR /go/src/github.com/openshift/cluster-api-provider-powervs
COPY . .
# VERSION env gets set in the openshift/release image and refers to the golang version, which interfers with our own
RUN unset VERSION \
&& GOPROXY=off NO_DOCKER=1 make build

FROM registry.ci.openshift.org/ocp/4.10:base
COPY --from=builder /go/src/github.com/openshift/cluster-api-provider-powervs/bin/machine-controller-manager /
127 changes: 127 additions & 0 deletions Makefile
@@ -0,0 +1,127 @@
# Copyright 2021 The Kubernetes Authors.
#
# 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
#
# http://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.

GO111MODULE = on
export GO111MODULE
GOFLAGS ?= -mod=vendor
export GOFLAGS
GOPROXY ?=
export GOPROXY

DBG ?= 0

ifeq ($(DBG),1)
GOGCFLAGS ?= -gcflags=all="-N -l"
endif

VERSION ?= $(shell git describe --always --abbrev=7)
REPO_PATH ?= github.com/openshift/cluster-api-provider-powervs
LD_FLAGS ?= -X $(REPO_PATH)/pkg/version.Raw=$(VERSION) -extldflags "-static"
MUTABLE_TAG ?= latest
IMAGE = origin-powervs-machine-controllers

.PHONY: all
all: generate build images check

NO_DOCKER ?= 0

ifeq ($(shell command -v podman > /dev/null 2>&1 ; echo $$? ), 0)
ENGINE=podman
else ifeq ($(shell command -v docker > /dev/null 2>&1 ; echo $$? ), 0)
ENGINE=docker
else
NO_DOCKER=1
endif

USE_DOCKER ?= 0
ifeq ($(USE_DOCKER), 1)
ENGINE=docker
endif

ifeq ($(NO_DOCKER), 1)
DOCKER_CMD =
IMAGE_BUILD_CMD = imagebuilder
else
DOCKER_CMD := $(ENGINE) run --rm -v "$(PWD)":/go/src/github.com/openshift/cluster-api-provider-powervs:Z -w /go/src/github.com/openshift/cluster-api-provider-powervs openshift/origin-release:golang-1.16
IMAGE_BUILD_CMD = $(ENGINE) build
endif

.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify

.PHONY: generate
generate: gogen goimports

gogen:
$(DOCKER_CMD) go generate ./pkg/... ./cmd/...

.PHONY: test
test: ## Run tests
@echo -e "\033[32mTesting...\033[0m"
$(DOCKER_CMD) hack/ci-test.sh

bin:
@mkdir $@

.PHONY: build
build: ## build binaries
$(DOCKER_CMD) CGO_ENABLED=0 go build $(GOGCFLAGS) -o "bin/machine-controller-manager" \
-ldflags "$(LD_FLAGS)" "$(REPO_PATH)/cmd/manager"

.PHONY: images
images: ## Create images
ifeq ($(NO_DOCKER), 1)
./hack/imagebuilder.sh
endif
$(IMAGE_BUILD_CMD) -t "$(IMAGE):$(VERSION)" -t "$(IMAGE):$(MUTABLE_TAG)" ./

.PHONY: push
push:
$(ENGINE) push "$(IMAGE):$(VERSION)"
$(ENGINE) push "$(IMAGE):$(MUTABLE_TAG)"

.PHONY: check
check: fmt vet lint test # Check your code

.PHONY: unit
unit: # Run unit test
$(DOCKER_CMD) go test -race -cover ./cmd/... ./pkg/...

.PHONY: test-e2e
test-e2e: ## Run e2e tests
hack/e2e.sh

.PHONY: lint
lint: ## Go lint your code
$(DOCKER_CMD) hack/go-lint.sh -min_confidence 0.3 $$(go list -f '{{ .ImportPath }}' ./... | grep -v -e 'github.com/openshift/cluster-api-provider-powervs/test' -e 'github.com/openshift/cluster-api-provider-powervs/pkg/client/mock')

.PHONY: fmt
fmt: ## Go fmt your code
$(DOCKER_CMD) hack/go-fmt.sh .

.PHONY: goimports
goimports:
$(DOCKER_CMD) hack/goimports.sh .
hack/verify-diff.sh

.PHONY: vet
vet: ## Apply go vet to all go files
$(DOCKER_CMD) hack/go-vet.sh ./...

.PHONY: help
help:
@grep -E '^[a-zA-Z/0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
8 changes: 8 additions & 0 deletions OWNERS
@@ -0,0 +1,8 @@
reviewers:
- mkumatag
- Karthik-K-N
approvers:
- mkumatag

component: "Cloud Compute"
subcomponent: "Other Providers"
88 changes: 88 additions & 0 deletions README.md
@@ -0,0 +1,88 @@
# Machine API Provider Power VS

This repository contains implementations of Power VS Provider for the
OpenShift [machine-api](https://github.com/openshift/cluster-api).

This provider runs as a machine-controller deployed by the
[machine-api-operator](https://github.com/openshift/machine-api-operator)

### How to build the images in the RH infrastructure
The Dockerfiles use `as builder` in the `FROM` instruction which is not currently supported
by the RH's docker fork (see [https://github.com/kubernetes-sigs/kubebuilder/issues/268](https://github.com/kubernetes-sigs/kubebuilder/issues/268)).
One needs to run the `imagebuilder` command instead of the `docker build`.

Note: this info is RH only, it needs to be backported every time the `README.md` is synced with the upstream one.

## Deploy machine API plane with kubernetes cluster

1. **Deploying the cluster**

Use any existing mechanism for deploying the kubernetes cluster, e.g: kubeadm https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/

2. **Deploying machine API controllers**

For development purposes the powervs machine controller itself will run out of the machine API stack.
Otherwise, docker images needs to be built, pushed into a docker registry and deployed within the stack.

To deploy the stack:
```
kustomize build config | kubectl apply -f -
```

3. **Deploy secret with Power VS credentials**

Power VS nodeupdate controller assumes existence of a secret file:

```yaml
apiVersion: v1
kind: Secret
metadata:
name: powervs-credentials
namespace: openshift-machine-api
type: Opaque
data:
ibmcloud_api_key: FILLIN
```

You can use `examples/render-powervs-secrets.sh` script to generate the secret:
```sh
# Set the IBMCLOUD_API_KEY with a proper IBM Cloud API Key
$ IBMCLOUD_API_KEY=<API_KEY> ./examples/render-powervs-secrets.sh examples/addons.yaml | kubectl apply -f -
```

Go to [How to create IBM Cloud API Key](#How-to-create-IBM-Cloud-API-Key) for creating API Key

4. **Test by creating example machine**

```shell
# Update the relevant fields like serviceInstanceID, imageID, subnets, keyName etc..
$ kubectl create -f examples/machine-with-user-data.yaml
$ kubectl create -f examples/userdata.yml
```
## Test locally built powervs actuator

1. **Tear down machine-controller**

Deployed machine API plane (`machine-api-controllers` deployment) is (among other
controllers) running `machine-controller`. In order to run locally built one,
simply edit `machine-api-controllers` deployment and remove `machine-controller` container from it.


2. **Build and run powervs actuator from outside the cluster**

```sh
$ go build -o bin/machine-controller-manager github.com/openshift/cluster-api-provider-powervs/cmd/manager
```

```sh
$ .bin/machine-controller-manager --kubeconfig ~/.kube/config --logtostderr -v 5 -alsologtostderr
```
If running in container with `podman`, or locally without `docker` installed, and encountering issues, see [hacking-guide](https://github.com/openshift/machine-api-operator/blob/master/docs/dev/hacking-guide.md#troubleshooting-make-targets).

## How to create IBM Cloud API Key

### Method 1: Create an API Key via IAM
https://cloud.ibm.com/docs/account?topic=account-userapikey&locale=en#create_user_key

### Method 2: Create an API Key via Service Account
<!TODO: Add information>