# Magic of CF push on K8s ## Let's light up Since it takes sometime to deploy the cf environment, we will deploy the Cloud foundry control plane components on the existing kubernetes clusters. For ease we already created a kubernetes cluster in [gardener](https://gardener.cloud) and pointed to the cluster in your system.You can verify it. * Check the current directory path to be "kubecf-appspace" . * There will be two helm chart repos "cf-operator" and "kubecf" ``` kubectl cluster-info ``` **Installing cf-operator** We use [helm](https://helm.sh/) package manager to deploy kubernetes workloads. ``` kubectl create ns kubecf helm template cf-operator --namespace kubecf --name cf-operator --set global.image.pullPolicy=Always --set operator.watchNamespace=kubecf -f values.yaml | kubectl apply -f - -n kubecf watch kubectl get pods -n kubecf ``` Wait till cf-operator and quarks-job pods starts running **Installing CF-control planes** ``` helm template kubecf --namespace kubecf --name kubecf -f values.yaml | kubectl apply -f - -n kubecf watch kubectl get pods -n kubecf ``` It will take approximately 10 minutes to get all the components to be running. Do a watch on the namespace, meanwhile let's go through the concepts. ## Let's Learn Cloud Foundry, the open-source platform-as-a-service project that more than half of the Fortune 500 companies use to help them build, test and deploy their applications, launched well before Kubernetes existed. Unsurprisingly, given the popularity of Kubernetes, which has become somewhat the de facto standard for container orchestration, a number of companies in the Cloud Foundry ecosystem starting looking into how they could use Kubernetes to replace Diego. ![](https://i.imgur.com/HIebi9Q.png) The result of this is Project [Quarks](https://github.com/cloudfoundry-incubator/cf-operator) and [Eirini](https://www.cloudfoundry.org/project-eirini/), which is driven from SAP, IBM and Suse. **Quarks** enables deployment of Bosh releases especially Cloud foundry to Kubernetes. It's implemented as a k8s operator, an active controller component which acts upon custom k8s resources. **Eirini** helps to deploy CF apps to a kube backend, using OCI images and Kube deployments.Eirini gives you the nice integrated cf push flow, with CF Apps mapped directly to kube StatefulSet. In other words it decouples buildpack staging and stateless-multitenant-app running. Eirini provides an "Orchestrator Provider Interface (OPI)" layer, that abstracts away orchestration from Cloud Foundry's control plane. .......Know more about [GARDENER](https://gardener.cloud) ## Let's Check Check the status of all the pods in *kubecf* namespace `kubectl get pods -n kubecf` You could see all containers are in Ready state. ``` NAME READY STATUS RESTARTS AGE cf-operator-quarks-job-6659b66fc-qk69j 1/1 Running 0 7h26m kubecf-adapter-v1-1 5/5 Running 0 7h26m kubecf-bits-v1-0 7/7 Running 0 7h26m kubecf-bits-v1-1 7/7 Running 0 7h20m kubecf-bosh-dns-7787b4bb88-6hhbq 1/1 Running 0 7h4m kubecf-bosh-dns-7787b4bb88-8wt98 1/1 Running 0 7h26m kubecf-cc-worker-v1-0 5/5 Running 0 7h26m kubecf-database-v1-0 5/5 Running 0 7h26m kubecf-diego-api-v1-0 6/6 Running 3 7h26m kubecf-eirini-v1-0 6/6 Running 14 7h26m kubecf-eirini-v1-1 6/6 Running 14 7h21m kubecf-log-api-v1-1 8/8 Running 0 7h26m kubecf-nats-v1-0 5/5 Running 0 7h26m kubecf-router-v1-1 6/6 Running 0 7h26m kubecf-scheduler-v1-0 10/10 Running 5 7h26m kubecf-singleton-blobstore-v1-0 7/7 Running 0 7h26m ``` ## Let's Push App Now CF deployment is completely ready. You can push any sample cloud foundry applications. ### Access the CF environment #### Get your CF Endpoint kubectl get ingress -n kubecf You will see hosts which will be your domain for CF Example: `ingress.kubecf-1.perftests.shoot.canary.k8s-hana.ondemand.com` #### Get your cf credentials to login to cf environment ``` kubectl get secrets kubecf.var-cf-admin-password -n kubecf -o go-template=="{{ .data.password | base64decode }}" ``` Copy the output which is your CF admin_password. **Ignore "=" in the output while copying** ``` cf api https://api.<INGRESS HOST> cf auth admin <PASSWORD> cf target -o system cf create-space test cf target -o system -s test ``` > Change the directory to *cf-sample* `cf push sample-app` Once application is started you can see that your application is deployed as statefulset in kubecf-eirini namespace ``` kubectl get statefulsets,pods -n kubecf-eirini ``` Kubernetes users can now try out the Cloud Foundry developer experience in a native, easy and interoperable way — **which means less YML, more code**. **clear the environmnent** ``` kubectl delete validatingwebhookconfiguration "cf-operator-hook-kubecf" kubectl delete mutatingwebhookconfiguration "cf-operator-hook-kubecf" kubectl delete ns kubecf kubecf-eirini ``` ## Please Leave your Footprints [HERE](https://forms.gle/cD71uiVUQcb2j1Ra6) HAPPY CODING :tada: