GithubHelp home page GithubHelp logo

qpc-github / k8s-config-connector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlecloudplatform/k8s-config-connector

1.0 2.0 0.0 57.3 MB

GCP Config Connector, a Kubernetes add-on for managing GCP resources

Home Page: https://cloud.google.com/config-connector/docs/overview

License: Apache License 2.0

Shell 0.43% Python 0.54% Go 98.18% Makefile 0.21% HTML 0.02% HCL 0.39% Dockerfile 0.24%

k8s-config-connector's Introduction

GCP Config Connector

Config Connector is a Kubernetes add-on that allows customers to manage GCP resources, such as Cloud Spanner or Cloud Storage, through your cluster's API.

With Config Connector, now you can describe GCP resources declaratively using Kubernetes-style configuration. Config Connector will create any new GCP resources and update any existing ones to the state specified by your configuration, and continuously makes sure GCP is kept in sync. The same resource model is the basis of Istio, Knative, Kubernetes, and the Google Cloud Services Platform.

As a result, developers can manage their whole application, including both its Kubernetes components as well as any GCP dependencies, using the same configuration, and -- more importantly -- tooling. For example, the same customization or templating tool can be used to manage test vs. production versions of an application across both Kubernetes and GCP.

This repository contains full Config Connector source code. This inlcudes controllers, CRDs, install bundles, and sample resource configurations.

Usage

See https://cloud.google.com/config-connector/docs/overview.

For simple starter examples, see the Resource reference and Cloud Foundation Toolkit Config Connector Solutions.

Building Config Connector

Recommended Operating System

  • Ubuntu (18.04/20.04)
  • Debian (9/10/11)

Software requirements

Set up your environment

Option 1: Set up an environment in a fresh VM (recommended)

  1. Create an Ubuntu 20.04 VM on Google Cloud.

  2. Open an SSH connection to the VM.

  3. Create a new directory for GoogleCloudPlatform open source projects if it does not exist.

    mkdir -p ~/go/src/github.com/GoogleCloudPlatform
  4. Update apt and install build-essential.

    sudo apt-get update
    sudo apt install build-essential
  5. Clone the source code.

    cd ~/go/src/github.com/GoogleCloudPlatform
    git clone https://github.com/GoogleCloudPlatform/k8s-config-connector
  6. Change to environment-setup directory.

    cd ~/go/src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/environment-setup
  7. Set up sudoless Docker.

    ./docker-setup.sh
  8. Exit your current session, then SSH back in to the VM. Then run the following to ensure you have set up sudoless docker correctly:

    docker run hello-world
  9. Install Golang.

    cd ~/go/src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/environment-setup
    ./golang-setup.sh
    source ~/.profile
  10. Install other build dependencies.

    ./repo-setup.sh
    source ~/.profile
  11. Set up a GKE cluster for testing purposes.

    NOTE: gcp-setup.sh assumes the VM you are running it from is in a GCP project which does not already have a GKE cluster with Config Connector already set up.

    ./gcp-setup.sh

Option 2: Set up an environment manually yourself

  1. Install all required dependencies

  2. Add all required dependencies to your $PATH.

  3. Set up a GOPATH.

  4. Add $GOPATH/bin to your $PATH.

  5. Clone the repository:

    cd $GOPATH/src/github.com/GoogleCloudPlatform
    git clone https://github.com/GoogleCloudPlatform/k8s-config-connector

Build the source code

  1. Enter the source code directory:

    cd $GOPATH/src/github.com/GoogleCloudPlatform/k8s-config-connector
  2. Build the controller:

    make manager
  3. Build the CRDs:

    make manifests
  4. Build the config-connector CLI tool:

    make config-connector

Create a Resource

  1. Enable Pub/Sub for your project.

    gcloud services enable pubsub.googleapis.com
  2. Create a Pub/Sub subscription. You may need to wait ~10-15 minutes to let your cluster get set up after running make deploy.

    cd $GOPATH/src/github.com/GoogleCloudPlatform/k8s-config-connector
    kubectl apply -f config/samples/resources/pubsubsubscription/basic-pubsub-subscription
  3. Wait a few minutes and then make sure your subscription exists in GCP.

    gcloud pubsub subscriptions list

    If you see a subscription, then your cluster is properly functioning and actuating K8s resources onto GCP.

Make a Code Change

At this point, your cluster is running a CNRM Controller Manager image built on your system. Let's make a code change to verify that you are ready to start development.

  1. Edit $GOPATH/src/github.com/GoogleCloudPlatform/k8s-config-connector/cmd/manager/main.go. Insert the log.Printf(...) statement below on the first line of the main() function.

    package manager
    
    func main() {
        log.Printf("I have finished the getting started guide.")
        ...
    }
  2. Build and deploy your change, force a pull of the container image.

    make deploy-controller && kubectl delete pods --namespace cnrm-system --all
  3. Verify your new log statement is on the first line of the logs for the CNRM Controller Manager pod.

    kubectl --namespace cnrm-system logs cnrm-controller-manager-0

Contributing to Config Connector

Please refer to our contribution guide for more details.

k8s-config-connector's People

Contributors

alexbulankou avatar caieo avatar diviner524 avatar jcanseco avatar kibbles-n-bytes avatar maqiuyujoyce avatar spew avatar toumorokoshi avatar tsawada avatar xiaobaitusi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.