nonk8sapi

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

Multicluster Global Hub API

This documentation is for the APIs of multicluster global hub resources. Multicluster global hub contains three resource categories: managed clusters, policies, application subscriptions. Each type of resource has two possible requests: list, get.

Get Started

  1. Install multicluster global hub and create some global hub resources(manged clusters, policies, application subscriptions)
  2. Log into the multicluster global hub cluster and retrieve the access token by running
export TOKEN=$(oc whoami -t)
  1. Get the host of multicluster global hub API
export GLOBAL_HUB_API_HOST=$(oc -n open-cluster-management get route multicluster-global-hub-manager -o jsonpath={.spec.host})
  1. Access the multicluster global hub API
  • List managed clusters:
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/managedclusters"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/managedclusters?limit=2"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/managedclusters?labelSelector=env%3Dproduction"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/managedclusters?labelSelector=env%3Dproduction&limit=2"
  • Patch label for managed cluster:
curl -sk -H "Authorization: Bearer $TOKEN" -X PATCH "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/managedcluster/<managed_cluster_uid>" -d '[{"op":"add","path":"/metadata/labels/foo","value":"bar"}]'
  • List policies:
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/policies"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/policies?limit=2"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/policies?labelSelector=env%3Dproduction"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/policies?labelSelector=env%3Dproduction&limit=2"
  • Get policy status with policy ID:
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/policy/<policy_uid>/status"
  • List subscriptions:
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/subscriptions"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/subscriptions?limit=2"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/subscriptions?labelSelector=env%3Dproduction"
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/subscriptions?labelSelector=env%3Dproduction&limit=2"
  • Get subscription report with subscription ID:
curl -sk -H "Authorization: Bearer $TOKEN" "https://$GLOBAL_HUB_API_HOST/global-hub-api/v1/subscriptionreport/<sub_uid>"

Contributing

If you want change the APIs, you need to follow the below steps to generate swagger document.

  1. Generate the rough swagger.yaml or swagger.json with swag
swag init -g ./non_k8s_api.go -o . --outputTypes "yaml" --parseDependency
  1. Edit the swagger.yaml or swagger.json manually for detailed API specification.

  2. Generate swagger markdown document with go-swagger

swagger generate markdown -f ./swagger.yaml --output ./swagger.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNonK8sApiServer

func AddNonK8sApiServer(mgr ctrl.Manager, database db.DB, nonK8sAPIServerConfig *NonK8sAPIServerConfig) error

AddNonK8sApiServer adds the non-k8s-api-server to the Manager.

func SetupRouter added in v0.7.0

func SetupRouter(database db.DB, nonK8sAPIServerConfig *NonK8sAPIServerConfig) (*gin.Engine, error)

@basePath /global-hub-api/v1 @schemes http https @securityDefinitions.apikey ApiKeyAuth @in header @name Authorization @description Authorization with user access token

Types

type NonK8sAPIServerConfig

type NonK8sAPIServerConfig struct {
	ClusterAPIURL          string
	ClusterAPICABundlePath string
	ServerBasePath         string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL