Difference between revisions of "IT-SDK-CloudFoundry"

From wiki.samerhijazi.net
Jump to navigation Jump to search
m (Samerhijazi moved page IT-Studing-CloudFoundry to IT-SDK-CloudFoundry without leaving a redirect)
(cf examples)
Line 167: Line 167:
 
$ cf create-service-key $NAME_SVC $NAME_SVC_KEY
 
$ cf create-service-key $NAME_SVC $NAME_SVC_KEY
 
$ cf service-key $NAME_SVC $NAME_SVC_KEY
 
$ cf service-key $NAME_SVC $NAME_SVC_KEY
 +
</pre>
 +
 +
=ReCap=
 +
<pre class="code">
 +
# Cloud
 +
 +
---
 +
## Pivotal Cloud Foundery
 +
https://pivotal.io/pcf-dev
 +
### Start PCF Dev
 +
```sh
 +
$ cf dev start
 +
$ cf login -a api.local.pcfdev.io --skip-ssl-validation
 +
```
 +
### Deploy the Sample App
 +
```sh
 +
$ git clone https://github.com/cloudfoundry-samples/spring-music
 +
$ cd .\spring-music
 +
$ .\gradlew.bat assemble
 +
```
 +
### Push App in Claoud
 +
```sh
 +
$ cf push --hostname spring-music
 +
```
 +
### View the Logs
 +
```sh
 +
$ cf logs spring-music --recent
 +
$ cf logs spring-music
 +
```
 +
### Connect a Database
 +
```sh
 +
$ cf marketplace -s p-mysql
 +
$ cf create-service p-mysql 512mb my-spring-db
 +
$ cf bind-service spring-music my-spring-db
 +
$ cf restart spring-music
 +
$ cf services
 +
```
 +
### Scale the App
 +
```sh
 +
$ cf app spring-music
 +
$ cf scale spring-music -i 2 # Increase the instances
 +
$ cf scale spring-music -m 1G # Increase the memory
 +
$ cf scale spring-music -k 512M # Increase the disk
 +
```
 +
---
 +
 
</pre>
 
</pre>

Revision as of 13:44, 3 January 2021

Resources

Commands

Setting

- api, target
- login, logout
- config
- buildpacks
- stacks

MgM Org

- orgs
- org-users, set-org-role, unset-org-role

MgM Space

- spaces
- create-space, delete-space
- space-users, set-space-role, unset-space-role

Applications

- apps, app
- push, delete
- start, stop, restart, restage, scale
- logs, events
- env, set-env
- ssh, run-task, create-app-manifest

Services

- marketplace
- services, service
- create-service, update-service, delete-service, bind-service, unbind-service

User-Provided-Service

- create-user-provided-service, update-user-provided-service
- service-keys, service-key
- create-service-key, delete-service-key
- bind-route-service, unbind-route-service

Route and domain

- domains, create-domain
- routers, create-route, delete-route, map-route, unmap-route

Manifest

---
applications:
- name: my-app
  memory: 750M
  instances: 1
  path: ./rest-data-service.jar
  timeout: 30
  #stack: cflinuxfs3
  #no-route: true
  #random-route: true
  routes:
   - route: my-app.eu-de.mybluemix.net
  buildpacks:
   - java_buildpack
  services:
   - mydb
  #docker:
    #image: docker-image-repository/docker-image-name
  env:
    ROSTER_A: AA
    ROSTER_B: BB
    RSOTER_C: BB

Ziele

CF-Life-Cycle

$ cf push $NAME_APP
$ cf scale $NAME_APP
$ cf app $NAME_APP
$ cf logs $NAME_APP
$ cf events $NAME_APP
$ cf restart $NAME_APP
$ cf marketplace
$ cf create-service $NAME_SERVICE
$ cf services
$ cf bind-service $NAME_APP $NAME_SERVICE
$ cf unbind-service $NAME_APP $NAME_SERVICE
$ cf env $NAME_APP
$ cf set-env $NAME_APP $VAR_NAME $NAR_VALUE
$ cf delete $NAME_APP

curl

$ curl -H "Content-Type:application/json" -X POST -d '{"firstName":"foo", "lastName":"bar"}' http://hijazi-app.eu-de.mybluemix.net/people

Exam-Values

$ cf push roster -p ./rest-data-service.jar -i 1 -m 750M -b java_buildpack --random-route --no-manifest
$ curl -H "Content-Type:application/json" -X POST -d '{"firstName":"foo", "lastName":"bar"}' http://hijazi-app.eu-de.mybluemix.net/people

cf examples

$ cf push $NAME_APP -p $PATH_FILE -i %VALUE_INSTANCE -m $VALUE_RAM -b $NAME_BUILDPACK --random-route --no-manifest
$ curl -H "Content-Type: application/json" -X POST -d '{"firstName":"foo","lastName":"bar"}' http://<YOUR-APP-URL>/people
$ cf scale $APP_NAME -m 1G
$ cf scale $APP_NAME -i 2
...
$ cf logs $APP_NAME
$ cf logs $APP_NAME --recent
$ cf events $APP_NAME
...
$ watch cf app roster
$ watch cf events roster
$ curl https://<YOUR-APP-URL>/kill
...
$ cf marketplace
$ cf create-service $SERVICE_NAME $SERVICE_PLAN $NAME_SVC
$ cf service $NAME_SVC
$ cf bind-service $NAME_APP $NAME_SVC
$ cf restage $NAME_SVC
...
$ cf env $NAME_APP
$ cf set-env $NAME_APP $NAME_VAR $VALUE_VAR
...
$ cf unbind-service $NAME_APP $NAME_SVC
$ cf delete $NAME_APP
...
$ cf push -f ./manifest.yaml
...
$ cf map-route $NAME_APP $NAME_DOMAIN -n $NAME_HOST
$ cf unmap-route $NAME_APP $NAME_DOMAIN -n $NAME_HOST
$ cf rename $NAME_APP $NAME_APP_NEW
$ cf restart $NAME_APP
...
$ cf cups $NAME_SVC -p $CREDENTIALS
$ cf push -f ./manifest.yaml --no-start
$ cf bind-service $NAME_APP $NAME_SVC
$ cf start $NAME_APP
...
$ cf push worker --docker-image engineerbetter/worker-image --no-start --no-route
...
$ cf create-service-key $NAME_SVC $NAME_SVC_KEY
$ cf service-key $NAME_SVC $NAME_SVC_KEY

ReCap

# Cloud

---
## Pivotal Cloud Foundery
https://pivotal.io/pcf-dev
### Start PCF Dev
```sh
$ cf dev start
$ cf login -a api.local.pcfdev.io --skip-ssl-validation
```
### Deploy the Sample App
```sh
$ git clone https://github.com/cloudfoundry-samples/spring-music
$ cd .\spring-music
$ .\gradlew.bat assemble
```
### Push App in Claoud
```sh
$ cf push --hostname spring-music
```
### View the Logs
```sh
$ cf logs spring-music --recent
$ cf logs spring-music
```
### Connect a Database
```sh
$ cf marketplace -s p-mysql
$ cf create-service p-mysql 512mb my-spring-db
$ cf bind-service spring-music my-spring-db
$ cf restart spring-music
$ cf services
```
### Scale the App
```sh
$ cf app spring-music
$ cf scale spring-music -i 2		# Increase the instances
$ cf scale spring-music -m 1G		# Increase the memory
$ cf scale spring-music -k 512M		# Increase the disk
```
---