From d6d9bdd56a19179f49a732dc5f1cfa9fbc498e2c Mon Sep 17 00:00:00 2001 From: Marco <marco.lorini@garr.it> Date: Mon, 12 Oct 2020 17:27:24 +0200 Subject: [PATCH] 2020-10-12 ML: add bash sections --- README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ca45b6e..4d5ba5c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To create the clusters on Openstack, it is possible to use the follow Juju bundl Once all the clusters for federation have been created, it is useful to collect all cluster access configurations (.kube/config) in a single config file. In this way you can easily switch from one cluster to another. Below is an example: -``` +```bash apiVersion: v1 clusters: - cluster: @@ -67,12 +67,12 @@ users: In this way you have access to all the clusters by the context switch, below are the commands for the context switch: list contexts: -``` +```bash $ kubectl config get-contexts ``` switch context: -``` +```bash $ kubectl config use-context <context-name> ``` @@ -82,7 +82,7 @@ $ kubectl config use-context <context-name> To install the KubeFed client run the following commands in your local machine: -``` +```bash $ VERSION=0.2.0-alpha.1 $ OS=linux $ ARCH=amd64 @@ -98,7 +98,7 @@ $ sudo mv kubefedctl /usr/local/bin/ # make sure the location is in the PATH To install the Controll Plane, switch to the host context and configuring the RBAC role for Tiller (in this case we use Helm v2): -``` +```bash $ cat << EOF | kubectl apply -f - apiVersion: v1 kind: ServiceAccount @@ -122,13 +122,14 @@ $ cat << EOF | kubectl apply -f - ``` helm init command: -``` + +```bash $ helm init --service-account tiller ``` Now it is possible install the Control Plane on the Host Cluster: -``` +```bash $ helm repo add kubefed-charts https://raw.githubusercontent.com/kubernetes-sigs/kubefed/master/charts $ helm install kubefed-charts/kubefed --name kubefed --version=0.2.0-alpha.1 --namespace kube-federation-system ``` @@ -142,21 +143,21 @@ $ helm install kubefed-charts/kubefed --name kubefed --version=0.2.0-alpha.1 --n To create a Kubernetes Federation it is necessary federate Member Clusters. Use the KubeFed `join` command: -``` +```bash $ kubefedctl join fed-cluster-member1 --cluster-context k8s-context-member1 --host-cluster-context k8s-context-host --v=2 $ kubefedctl join fed-cluster-member2 --cluster-context k8s-context-member2 --host-cluster-context k8s-context-host --v=2 ``` Remove cluster to the federation, `unjoin` command: -``` +```bash $ kubefedctl unjoin fed-cluster-member1 --cluster-context k8s-context-member1 --host-cluster-context k8s-context-host --v=2 $ kubefedctl unjoin fed-cluster-member2 --cluster-context k8s-context-member2 --host-cluster-context k8s-context-host --v=2 ``` Command to show federated clusters: -``` +```bash $ kubectl -n kube-federation-system get kubefedclusters ``` @@ -165,19 +166,19 @@ $ kubectl -n kube-federation-system get kubefedclusters To enable a type of resource to be federated it is necessary to use the enable command of kubefedctl: -``` +```bash $ kubefedctl enable <api-resources-name.api-group> --kubefed-namespace kube-federation-system ``` To know the list of resourses: -``` +```bash $ kubectl api-resources -o wide ``` Some examples: -``` +```bash $ kubefedctl enable deployments.apps --kubefed-namespace kube-federation-system $ kubefedctl enable services --kubefed-namespace kube-federation-system $ kubefedctl enable ingresses.extensions --kubefed-namespace kube-federation-system @@ -185,7 +186,7 @@ $ kubefedctl enable ingresses.extensions --kubefed-namespace kube-federation-sys Command to disable federated API: -``` +```bash $ kubefedctl disable services --kubefed-namespace kube-federation-system ``` -- GitLab