gyliu513 / roadmap

Daily Work
Apache License 2.0
16 stars 13 forks source link

Update README.md - 1 #3

Open gyliu513 opened 7 years ago

gyliu513 commented 7 years ago

test quota

Quota finished

abc def ghi

Finished quota

package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type FooSpec struct {
        Replicas int `json:"replicas"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/client.Object
type Foo struct {
        metav1.TypeMeta   `json:",inline"`
        metav1.ObjectMeta `json:"metadata,omitempty"`
        Spec FooSpec `json:"spec"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/client.Object
type FooList struct {
        metav1.TypeMeta `json:",inline"`
        metav1.ListMeta `json:"metadata,omitempty"`
        Items []Foo `json:"items"`
}
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type FooSpec struct {
        Replicas int `json:"replicas"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/client.Object
type Foo struct {
        metav1.TypeMeta   `json:",inline"`
        metav1.ObjectMeta `json:"metadata,omitempty"`
        Spec FooSpec `json:"spec"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/client.Object
type FooList struct {
        metav1.TypeMeta `json:",inline"`
        metav1.ListMeta `json:"metadata,omitempty"`
        Items []Foo `json:"items"`
}

Table of Contents generated with DocToc

Development Quick Start

This tutorial introduces how to create a nested controlplane from source code for development. CAPN should work with any standard Kubernetes cluster out of box, but for demo purposes, in this tutorial, we will use a kind cluster as the management cluster as well as the nested workload cluster.

Prerequisites

Please install the latest version of kind and kubectl

Create kind cluster

kind create cluster --name=capn

Clone CAPN

git clone https://github.com/kubernetes-sigs/cluster-api-provider-nested
cd cluster-api-provider-nested

Install cert-manager

Cert Manager is a soft dependency for the Cluster API components to enable mutating and validating webhooks to be auto deployed. For more detailed instructions go Cert Manager Installion.

kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml

Clone CAPI and Deploy Dev release

As a cluster API~(CAPI) provider, CAPN requires core components of CAPI to be setup. We need to deploy the unreleased version of CAPI for v1alpha4 API support.

git clone git@github.com:kubernetes-sigs/cluster-api.git
cd cluster-api
make release-manifests
# change feature flags on core
sed -i'' -e 's@- --feature-gates=.*@- --feature-gates=MachinePool=false,ClusterResourceSet=true@' out/core-components.yaml
kubectl apply -f out/core-components.yaml
cd ..

Create Docker Images, Manifests and Load Images

PULL_POLICY=Never TAG=dev make docker-build release-manifests
kind load docker-image gcr.io/cluster-api-nested-controller-amd64:dev --name=capn
kind load docker-image gcr.io/nested-controlplane-controller-amd64:dev --name=capn

Deploy CAPN

Next, we will deploy the CAPN related CRDs and controllers.

kubectl apply -f out/cluster-api-provider-nested-components.yaml 

Apply Sample Cluster

kubectl apply -f config/samples/

Get KUBECONFIG

We will use the clusterctl command-line tool to generate the KUBECONFIG, which will be used to access the nested controlplane later.

cd cluster-api
make clusterctl
./bin/clusterctl get kubeconfig cluster-sample > ../kubeconfig
cd ..

Port Forward

To access the nested controlplane, in a separate shell, you will need to port-forward the apiserver service.

kubectl port-forward svc/cluster-sample-apiserver 6443:6443

Connect to Cluster

To use the KUBECONFIG created by clusterctl without modification, we first need to setup a host record for the apiserver service name, to do this need add following line to /etc/hosts.

127.0.0.1 cluster-sample-apiserver

Connect to the Cluster! :tada:

kubectl --kubeconfig kubeconfig get all -A

Clean Up

kind delete cluster --name=capn