Giter Club home page Giter Club logo

gcp-project-operator's Introduction

GCP Project Operator

Go Report Card Go Coverage GoDoc License

GCP Project Operator


GCP Project Operator is an open source project responsible for creating and destroying projects and service accounts in GCP. It stores the credentials in a secret, so other Kubernetes applications (operators) can use them and interact with GCP to create cloud resources or any other underlying infrastructure (such as storage or virtual machines).

GCP Project Operator is one of the operators used for provisioning OpenShift Dedicated clusters on Google Cloud Platform managed by Red Hat Site-Reliability Engineers.

You can get a quick overview of what's happening inside the Operator by watching this video.

If you like to contribute to GCP Project Operator, please be so kind to read our Contribution Policy first.


Info

Documentation

For Users

  • Google GCP configuration -- The Operator expects a ConfigMap and a Secret to be already present in the cluster before you use it.
  • How to use it -- Tell the Operator to create or delete a new GCP Project for you.
  • Debugging -- Useful tips and commands.
  • API -- Options you can fine-tune for ProjectClaim.

For Developers

  • Design -- Describes the interaction between the custom resource definitions.
  • Building -- Instructions for building the project.
  • Development -- Instructions for developers who want to contribute.
  • Testing -- Instructions for writing tests.
  • Troubleshooting -- Common errors and pitfalls.
  • Code Analysis -- A high-level analysis of the code to get yourself familiar with the codebase.

Workflow - ProjectClaim

  1. The operator watches all namespaces for ProjectClaim resources.
  2. When a ProjectClaim is found (see example below) the operator triggers the creation of a project in GCP.
  3. After successful project creation:
    • The field State will be set to Ready.
    • A secret is created in the cluster namespace, as defined in the ProjectClaim.
    • The field spec.gcpProjectID will be filled with the ID of the GCP project.
    • A list of available zones in the input region is set in spec.availabilityZones.
  4. When a ProjectClaim is removed, the secret, the GCP project and its ServiceAccounts are deleted.
  5. The operator removes the finalizer from the ProjectClaim.

Example Input Custom Resource

apiVersion: gcp.managed.openshift.io/v1alpha1
kind: ProjectClaim
metadata:
  name: example-projectclaim
  namespace: example-clusternamespace
spec:
  region: us-east1
  gcpCredentialSecret:
    name: gcp-secret
    namespace: example-clusternamespace
  legalEntity:
    name: example-legal-entity
    id: example-legal-entity-id

Deployment

Building

Just run make.

Local Dev

Prerequisites

  • Typically you'll want to use CRC, though it's fine if you're running OpenShift another way.
  • You need to have the operator-sdk binary in your $PATH.

Start operator locally

oc new-project gcp-project-operator
oc apply -f deploy/crds/gcp.managed.openshift.io_projectclaims.yaml
oc apply -f deploy/crds/gcp.managed.openshift.io_projectreferences.yaml

operator-sdk up local --namespace gcp-project-operator

NOTE: The above command works with operator-sdk v0.11.0. If it fails to run, try using one of the older commands:

operator-sdk run --local --namespace gcp-project-operator
operator-sdk run local --watch-namespace gcp-project-operator

If everything went ok, you should see some startup logs from the operator in your terminal window.

There are example CRs in deploy/crds/ you might want to use to see how the operator reacts to their presence (and absence if you delete them).

Running tests

You can run the tests using make gotest or go test ./...

Configuration

For the operator to interact with GCP properly, it needs a bit of configuration first.

Note: unless you're running this against your very own GCP org, someone likely already has this stuff prepared for you. Ask around.

Auth Secret

  1. Create a gcp service account with appropriate permissions to an empty folder ("(Project) Owner" and "Project Creator" should suffice).
  2. Generate keys for the service account and download them.
  3. Run oc create -n gcp-project-operator secret generic gcp-project-operator-credentials --from-file=key.json=YOUR-KEYS-FILE-NAME.json

Configmap

The controller expects to find a ConfigMap with the name gcp-project-operator inside the gcp-project-operator namespace.

For how to create a ConfigMap, please refer to the doc.

gcp-project-operator's People

Contributors

2uasimojo avatar bmeng avatar boranx avatar cblecker avatar dependabot[bot] avatar drewandersonnz avatar drpaneas avatar georgettica avatar jharrington22 avatar jnpacker avatar maorfr avatar mjlshen avatar mmazur avatar mwoodson avatar nautilux avatar ninabauer avatar npecka avatar openshift-ci[bot] avatar openshift-merge-bot[bot] avatar openshift-merge-robot avatar rafael-azevedo avatar ramonbutter avatar rogbas avatar sam-nguyen7 avatar supreeth7 avatar tessg22 avatar thrasher-redhat avatar typeid avatar yeya24 avatar zmird-r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gcp-project-operator's Issues

why change the spec of the cr?

Is this kind of operation(operator changes the spec of CR) recommended? Why not make the terms need to be changed into status?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.