Last active
October 18, 2018 09:25
-
-
Save shashidharatd/6fca02d59cf9f82a63ff4507b36c3365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Create minikube cluster cluster1 | |
$> minikube start --kubernetes-version v1.11.3 -p cluster1 | |
# 2. Deploy metallb (for loadbalancers) | |
$> kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml | |
$> cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
namespace: metallb-system | |
name: config | |
data: | |
config: | | |
address-pools: | |
- name: my-ip-space | |
protocol: layer2 | |
addresses: | |
- 192.168.99.220/29 | |
EOF | |
# 3. Deploy ingress-controller behind a loadbalancer. | |
$> helm init | |
$> helm install stable/nginx-ingress --name nginx --namespace kube-system --set rbac.create=true --set controller.publishService.enabled=true | |
# 4. repeat above steps for cluster2. Note: use a different ip segment for metallb-config like 192.168.99.210/29 | |
# 5. Deploy federation in cluster1 and join cluster1 & cluster2 to federation. | |
# Not prescribing how to install. please refer to federation guide. :) | |
$> kubectl config use-context cluster1 | |
# 6. Deploy external-dns in cluster1 for Google Cloud DNS provider | |
# Download the service-account for Google cloud (say credentials.json) | |
# Create a secret using credentials.json | |
$> kubectl -n federation-system create secret generic gcloud-config --from-file=./credentials.json | |
$> helm install --namespace federation-system --name globaldns \ | |
--set provider=google \ | |
--set google.project="xxx" \ | |
--set google.serviceAccountSecret="gcloud-config" \ | |
--set sources={crd} \ | |
--set extraArgs.crd-source-apiversion=multiclusterdns.federation.k8s.io/v1alpha1 \ | |
--set extraArgs.crd-source-kind=DNSEndpoint \ | |
stable/external-dns | |
#Note: substitute your google project in google.project above | |
# 7. Now testing...... | |
# Deploy replicaset, service, ingress and ingressdnsrecord | |
$> cat <<EOF | kubectl apply -f - | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedReplicaSet | |
metadata: | |
name: fr1 | |
spec: | |
template: | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: demo | |
template: | |
metadata: | |
name: demo | |
labels: | |
app: demo | |
spec: | |
containers: | |
- name: demo | |
image: shashidharatd/fed-sd-demo | |
ports: | |
- containerPort: 80 | |
env: | |
- name: MY_NODE_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: spec.nodeName | |
- name: MY_POD_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.name | |
- name: MY_POD_IP | |
valueFrom: | |
fieldRef: | |
fieldPath: status.podIP | |
--- | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedService | |
metadata: | |
name: fs1 | |
spec: | |
template: | |
spec: | |
selector: | |
app: demo | |
ports: | |
- protocol: TCP | |
port: 80 | |
targetPort: 80 | |
--- | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedIngress | |
metadata: | |
name: fi1 | |
spec: | |
template: | |
spec: | |
rules: | |
- host: foo.fing.f8n.org | |
http: | |
paths: | |
- backend: | |
serviceName: fs1 | |
servicePort: 80 | |
--- | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedReplicaSetPlacement | |
metadata: | |
name: fr1 | |
spec: | |
clusterNames: | |
- cluster1 | |
- cluster2 | |
--- | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedServicePlacement | |
metadata: | |
name: fs1 | |
spec: | |
clusterNames: | |
- cluster1 | |
- cluster2 | |
--- | |
apiVersion: core.federation.k8s.io/v1alpha1 | |
kind: FederatedIngressPlacement | |
metadata: | |
name: fi1 | |
spec: | |
clusternames: | |
- cluster1 | |
- cluster2 | |
--- | |
apiVersion: multiclusterdns.federation.k8s.io/v1alpha1 | |
kind: MultiClusterIngressDNSRecord | |
metadata: | |
name: fi1 | |
spec: | |
hosts: | |
- foo.fing.f8n.org | |
recordTTL: 180 | |
EOF | |
# That's all... now you can test whether it works | |
# curl foo.fing.f8n.org |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment