cf.cheat 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. % cf, pcf, pivotal cloud foundry, paas
  2. ### Information
  3. # Get the extended list of help
  4. cf help -a
  5. # Get current version of cf
  6. cf version
  7. # Get information about current org
  8. cf org
  9. # Get information about current space
  10. cf space
  11. # Get information about current target
  12. cf target
  13. # Get list of all apps
  14. cf apps
  15. # Get list of all services
  16. cf services
  17. # Get list of all routes
  18. cf routes
  19. # Get list of all network policies
  20. cf network-policies
  21. ### Login
  22. # Login to your CF/PCF instance
  23. cf login -a <API_URL>
  24. # Login to your CF/PCF instance with username and password
  25. cf login -a <API_URL> -u <USERNAME> -p <PASSWORD>
  26. # Login and specify target directly
  27. cf login -a <API_URL> -u <USERNAME> -p <PASSWORD> -o <ORG> -s <SPACE>
  28. ### Target
  29. # Set target org
  30. cf target -o <org>
  31. # Set target space
  32. cf target -o <org> -s <space>
  33. ### Application manipulation
  34. ## Information
  35. # Get the guid of an app
  36. cf app <app> --guid
  37. # Get the status of an app
  38. cf app <app>
  39. ## Status
  40. # Start an app
  41. cf start <app>
  42. # Stop an app
  43. cf stop <app>
  44. # Restart an app
  45. cf restart <app>
  46. # Rebuild the application package and restart
  47. cf restage <app>
  48. ## Deletion
  49. # Delete an app
  50. cf delete <app>
  51. # Delete an app no prompt
  52. cf delete <app> -f
  53. # Delete an app and routes
  54. cf delete <app> -r
  55. ### Networking - A bit slow due to filtering
  56. # Add network policy
  57. cf add-network-policy <add_network_source> \
  58. --destination-app <add_network_destination> \
  59. --protocol <add_network_protocol> \
  60. --port <add_network_port>
  61. # Remove network-policy
  62. cf remove-network-policy <remove_network_source> \
  63. --destination-app <remove_network_destination> \
  64. --protocol <remove_network_protocol> \
  65. --port <remove_network_port>
  66. ### Services
  67. # Bind a service to an application
  68. cf bind-service <app> <service>
  69. # Unbind a service from an application
  70. cf unbind-service <app> <service>
  71. # Share a service between spaces
  72. cf share-service <service> -o <org> -s <space>
  73. # Unshare a service from a spaces
  74. cf unshare-service <service> -o <org> -s <space>
  75. # Autocomplete variables
  76. $ org: cf orgs | awk 'NR>3 {print}'
  77. $ space: cf target -o "$org" > /dev/null && cf spaces | awk 'NR>3 {print $1}'
  78. $ service: cf services | awk 'NR>3 {print $1}' | sed '/TIP:/d'
  79. $ route: cf routes | awk 'NR>3 {if ($4 ~ /^\//){ print $2 "." $3 $4} else {print $2 "." $3}}'
  80. $ app: cf apps | awk 'NR>4 {print $1}'
  81. $ add_network_source: cf apps | awk 'NR>4 {print $1}'
  82. $ add_network_destination: cf apps | awk 'NR>4 {print $1}' | sed "/$add_network_source/d"
  83. $ add_network_protocol: printf "tcp \nudp"
  84. $ remove_network_source: cf network-policies | awk 'NR>3 {print $1}' | uniq
  85. $ remove_network_destination: cf network-policies | grep "^$remove_network_source" | awk '{print $2}' | uniq
  86. $ remove_network_protocol: cf network-policies | grep "^$remove_network_source" | grep "$remove_network_destination" | awk '{print $3}' | uniq
  87. $ remove_network_port: cf network-policies | grep "^$remove_network_source" | grep "$remove_network_destination" | awk '{print $4}' | uniq