Giter VIP home page Giter VIP logo

cloud-prepare's Introduction

Submariner cloud-prepare

CII Best Practices

Submariner's cloud-prepare is a Go library that provides API and capabilities for setting up cloud infrastructure in order to install Submariner.

API

The main API defines the capabilities for any Cloud:

  • Preparing the cloud for setting up Submariner.
  • Cleaning up the cloud after Submariner has been uninstalled.

These capabilities aim to be idempotent, so in case of failure or other necessity they are safe to re-run.

The API defines a Reporter type which has the capability to report on the latest operation performed in the cloud.

Prepare a cloud for Submariner

The PrepareForSubmarinerInput function takes the number of gateways, the internal ports used for intra-cluster communication between Submariner components, and the public ports used for inter-cluster communication between Submariner gateways.

	input := api.PrepareForSubmarinerInput{
		InternalPorts: []api.PortSpec{
			{Port: vxlanPort, Protocol: "udp"},
			{Port: metricsPort, Protocol: "tcp"},
		},
		PublicPorts: []api.PortSpec{
			{Port: nattPort, Protocol: "udp"},
			{Port: natDiscoveryPort, Protocol: "udp"},
		},
		Gateways: gateways,
	}
	err := cloud.PrepareForSubmariner(input, reporter)

Clean up a cloud after Submariner has been uninstalled

The CleanupAfterSubmariner function reverses all the preparation work previously done by the library.

	err := cloud.CleanupAfterSubmariner(reporter)

Supported Cloud Providers

AWS

In order to prepare an AWS instance, it needs to have OpenShift pre-installed and running.

	// The gwDeployer deploys the gateway and is pluggable.
	// This one deploys straight to K8s using MachineSet.
	gwDeployer := cloudprepareaws.NewK8sMachinesetDeployer(k8sConfig)

	// Create a new Cloud from an existing AWS session;
	// infraID, region and gwInstanceType are necessary to properly deploy on AWS.
	cloud := cloudprepareaws.NewCloud(
		gwDeployer, ec2.New(awsSession), infraID, region, gwInstanceType)

GCP

In order to prepare a GCP instance, it needs to have OpenShift pre-installed and running.

	import (
		"golang.org/x/oauth2/google"
		dns "google.golang.org/api/dns/v1"
		gcpclient "github.com/submariner-io/cloud-prepare/pkg/gcp/client"
		cloudpreparegcp "github.com/submariner-io/cloud-prepare/pkg/gcp"
	)

	// Create Google credentials from a JSON value.
	// The JSON can represent either a Google Developers Console client_credentials.json file (as in ConfigFromJSON)
	// or a Google Developers service account key file (as in JWTConfigFromJSON).
	credentials, err := google.CredentialsFromJSON(context.TODO(), authJSON, dns.CloudPlatformScope)
	if err != nil {
		t.Fatal(err)
	}

	// Create a GCP client with the credentials.
	client, err := gcpclient.NewClient([]option.ClientOption{option.WithCredentials(credentials)})
	if err != nil {
		return err
	}

	// Create a new Cloud with the GCP client and the projectID of the credentials, infraID is necessary to properly deploy on GCP.
	cloud := cloudpreparegcp.NewCloud(credentials.ProjectID, infraID, client)

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.