|
| 1 | +Explanatory document for the use of *GCP* |
| 2 | +============================================= |
| 3 | + |
| 4 | +In this document you will learn how to use mainly *GCP* for TimeSide |
| 5 | +but also for other use. |
| 6 | + |
| 7 | +We will therefore see in this document: |
| 8 | + |
| 9 | +- What is *GCP* ? |
| 10 | +- What to do now that we know what GCP is? |
| 11 | +- Explanation of the home page |
| 12 | +- Explanation of the main menu bar |
| 13 | +- Explanation of the menu navigation |
| 14 | +- Some additional points to know |
| 15 | +- Some commands and example |
| 16 | +- To create a **VM LINUX** |
| 17 | +- To create a **VM WINDOWS** |
| 18 | +- Creation **KUBERNETES** |
| 19 | +- TUTORIAL |
| 20 | +- **Kompose** a means of obtaining .yaml files |
| 21 | +- |
| 22 | + |
| 23 | +### What is *GCP* ? |
| 24 | + |
| 25 | +First you need to know what *GCP* is before you continue. It is the |
| 26 | +acronym of **Google Cloud Platform** and is a cloud computing |
| 27 | +platform provided by Google, offering accommodation on the same |
| 28 | +infrastructure as that which Google uses internally as for its search |
| 29 | +engine. *Cloud Platform* provides developers with products to build |
| 30 | +a range of programs from simple websites to complex applications. |
| 31 | + |
| 32 | +*GCP* is part of a set of solutions for companies called **Google Cloud**, and provides modular cloud-based services, such as information storage, calculation, translation and forecasting applications , etc. |
| 33 | + |
| 34 | +### What to do now that we know what GCP is? |
| 35 | + |
| 36 | +One of the first things would be to understand the navigation menu and |
| 37 | +the welcome. |
| 38 | + |
| 39 | +##### is an example of the home and its explanation |
| 40 | + |
| 41 | + |
| 43 | + |
| 44 | +The body of the page contains several different customizable widgets |
| 45 | +that provide information, reports, statistics and help regarding the |
| 46 | +current project and GCP in general. Each of them offers a contextual |
| 47 | +menu which allows either to access the associated documentation, or to |
| 48 | +hide this widget and almost all of them provide a navigation button at |
| 49 | +the bottom which will lead to the associated service, some of them will |
| 50 | +offer additional choices in according to their content, such as editing |
| 51 | +the graph or adding others. |
| 52 | + |
| 53 | +Going back to the description of the image: |
| 54 | + |
| 55 | +1. **Project info** - it specifies the basic information related |
| 56 | + to the current project, like *name*, *ID*, *number*. |
| 57 | +2. **Resources** - it lists the main resources / components used |
| 58 | + in the project. |
| 59 | +3. **Trace** - if Stackdriver Trace is enabled, it provides the |
| 60 | + latest trace data. |
| 61 | +4. **Getting started** - it links to quick tutorials of the most |
| 62 | + common operations. |
| 63 | +5. **APIs** - a graph showing the requests per second to the *APIs* used by the project. |
| 64 | +6. **Computer Engine** - it shows a graph related to the usage of |
| 65 | + one instance of **Computer Engine**, by default it's count / |
| 66 | + sec, but you can specify different parameters for the main graph or |
| 67 | + add a new one . |
| 68 | +7. **Google Cloud Platform Status** - as the name implies it |
| 69 | + reports the status of **GCP** *services*, in the unlikely |
| 70 | + scenario that some outage occurs. |
| 71 | +8. **Billing** - it shows an estimate of the charges related to |
| 72 | + this project in the current period. |
| 73 | +9. **Error reporting** - it shows the last 24 hours errors |
| 74 | + collected by Stackdriver error reporting. |
| 75 | +10. **News** - It aggregates the feeds of news related to **GCP** and **Cloud** in general. |
| 76 | +11. **Documentation** - Hot links to **GCP** documentation. |
| 77 | + |
| 78 | +##### If we go to the top of the page we reach the main menu bar: |
| 79 | + |
| 80 | +1. **Navigation menu** - it expands and lists all the most |
| 81 | + relevant **GCP** component grouped by category, more on this |
| 82 | + later. |
| 83 | +2. **Navigation link to the Dashboard** - useful if you're in a |
| 84 | + product's page and you want to quickly navigate back. |
| 85 | +3. **Project selector** - it will display a pop-up window |
| 86 | + allowing you to select the current project. |
| 87 | +4. **Search bar** - it allows you to search full text among the |
| 88 | + products, services and functionalities offered by GCP. |
| 89 | +5. **Cloud Shell** - this button provides command-line access to |
| 90 | + a virtual machine instance in a terminal window that opens in the |
| 91 | + web console, more on this later. |
| 92 | +6. **Help** - it shows a contextual pop-up window with articles |
| 93 | + and support options. |
| 94 | +7. **Notifications** - it will aggregate and notify about |
| 95 | + relevant events regarding your project and account. |
| 96 | +8. **Settings** - it allows you to set your project preferences, |
| 97 | + a direct link to tools downloads, ect ... |
| 98 | +9. **Google Account** - as it's easy to guess it shows |
| 99 | + information related to the account with which you're currently |
| 100 | + logged in, allowing you to log out or add other accounts. |
| 101 | + |
| 102 | +##### Explanation Navigation menu |
| 103 | + |
| 104 | +Now let's take a closer look at the **Navigation menu**, by |
| 105 | +clicking on it a menu opens and offers a lot of categories. We will |
| 106 | +treat the categories in general and not point by point for more |
| 107 | +information on these categories use this |
| 108 | +[link](https://cloud.google.com/docs/overview/cloud-platform-services#top_of_page). |
| 109 | + |
| 110 | +| Category | Utility | |
| 111 | +| ------------- | -------- | |
| 112 | +| **Compute** | hosts a variety of machine types that support any type of workload. The different IT options allow you to decide to what extent you want to get involved in operational details and infrastructure, among others.| |
| 113 | +| **Storage** | data storage and database options for structured or unstructured, relational or non-relational data.| |
| 114 | +| **Networking** | services that balance application traffic and provide, among other things, security rules.| |
| 115 | +| **Cloud Operations** | a suite of logging, monitoring, tracking, and other reliability tools for inter-cloud services | |
| 116 | +| **Tools** | services for developers managing application creation deployments and pipelines.| |
| 117 | +| **Big Data** | services that allow you to process and analyze large data sets.| |
| 118 | +| **Artificial Intelligence** | a suite of APIs that perform specific artificial intelligence and machine learning tasks on Google Cloud.| |
| 119 | + |
| 120 | + |
| 121 | +##### Some additional points to know: |
| 122 | + |
| 123 | +In the navigation menu, near the top, is **IAM and admin**. This |
| 124 | +will take you to a page that contains a list of users, which specifies |
| 125 | +the permissions and roles granted to certain accounts. |
| 126 | + |
| 127 | +Here is a table: |
| 128 | + |
| 129 | +| Role name | Authorizations | |
| 130 | +|---------------- | ----------------- | |
| 131 | +| roles / spectator | Permissions for read-only actions that do not affect the state, such as viewing (but not editing) existing resources or data. | |
| 132 | +| roles / editor | All viewer permissions, plus permissions for actions that change the state, such as modifying existing resources.| |
| 133 | +| roles / owner | All permissions and permissions from the editor for the following actions: Manage roles and permissions for a project and all project resources; Configure billing for a project.| |
| 134 | + |
| 135 | +In the navigation menu near the top is **API and services\> Library**. This will take you to a page that contains a list of *APIs* |
| 136 | +and in the left menu different types of categories will be offered. If |
| 137 | +you are looking for a particular API just search for it in the search |
| 138 | +bar at the top of the page. |
| 139 | + |
| 140 | +You can also learn more about the APIs by consulting the new practical |
| 141 | +tool from Google Cloud called [Google APIs |
| 142 | +Explorer](https://developers.google.com/apis-explorer/#p/). |
| 143 | + |
| 144 | +**GCP** also has its own command prompt: **CLOUD SHELL**. |
| 145 | +When you press the button, your personal Admin Machine will be |
| 146 | +instantiated and you'll connect to it. You will have terminal access to |
| 147 | +a command-line Linux environment, with persistent storage (5 Gb) from |
| 148 | +which you can manage all your cloud resources. The most common |
| 149 | +development tools are pre-installed as well as the most used admin tools |
| 150 | +like Docker, Kubernetes, MySql. The Cloud Shell Environment is a docker |
| 151 | +container, there is a default, Google maintained one, but it's possible |
| 152 | +to specify a different one if you fancy so. Cloud Shell also includes a |
| 153 | +few nice treats, like a Web Preview for your services and an online |
| 154 | +visual code editor. |
| 155 | + |
| 156 | +gcloud auth list This command displays an - authentication list - which |
| 157 | +lists the accounts authenticated in our Google Cloud project. |
| 158 | + |
| 159 | +### Some commands and example |
| 160 | + |
| 161 | +After having seen the basis of **GCP** it is so much to see some |
| 162 | +interesting examples and thus understand the facility to create what is |
| 163 | +necessary with **GCP**. |
| 164 | + |
| 165 | +##### To create a **VM LINUX** we have 2 ways: |
| 166 | + |
| 167 | +- With the cloud console: **Navigation menu\> Compute Engine\> VM |
| 168 | + Instances** then fill in the fields and end up doing **create |
| 169 | + ** . Then the machine should appear in **VM Instances**. |
| 170 | + |
| 171 | +- With **gcloud** : Just follow the following commands by entering |
| 172 | + them in **CLOUD SHELL** : |
| 173 | + `''gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone us- central1-c` |
| 174 | + '' |
| 175 | + |
| 176 | +`''gcloud compute instances create --help` '' (if we want to see the |
| 177 | +default values) |
| 178 | + |
| 179 | +If we always work in the same region and zone enter these two commands |
| 180 | +will avoid have to specify them during creation: |
| 181 | +`''gcloud config set compute / zone (name_zone)` '' |
| 182 | + |
| 183 | +`''gcloud config set compute / region (name_region)` '' |
| 184 | + |
| 185 | +(We will no longer have to specify --zone every time.) |
| 186 | + |
| 187 | +To use SSH with gcloud you have to do: |
| 188 | +`''gcloud compute ssh gcelab2 --zone us-central1-c` '' Then follow what |
| 189 | +is said and finally exit with exit . To install an NGINX server: |
| 190 | +`''sudo su -` '' `'' apt-get update` '' (update the operating system) |
| 191 | +`''apt-get install nginx -y` '' (install nginx) |
| 192 | +`''ps auwx | grep nginx` '' (check nginx) Then open new page and go: |
| 193 | +http://EXTERNAL\_IP/ |
| 194 | + |
| 195 | +gcloud offers an order for more information on his project in particular |
| 196 | +to know the default zones and regions: |
| 197 | +`''gcloud compute project-info describe --project <your_project_ID>` '' |
| 198 | + |
| 199 | +Environment variable: `''export PROJECT_ID = <your_project_ID>` '' |
| 200 | + |
| 201 | +It would therefore be possible to issue this command to create a VM: |
| 202 | +`''gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone $ ZONE` '' |
| 203 | + |
| 204 | +##### To create a **VM WINDOWS** follow this [tutorial](https://google.qwiklabs.com/focuses/560?parent=catalog). |
| 205 | + |
| 206 | +##### Creation **KUBERNETES** |
| 207 | + |
| 208 | +- *Creation cluster*: `'' gcloud container clusters create [CLUSTER-NAME]` '' |
| 209 | + |
| 210 | +- *Authenticate cluster*: |
| 211 | + `''gcloud container clusters get-credentials [ CLUSTER-NAME]` '' |
| 212 | + |
| 213 | +- *Deploy an application*: |
| 214 | + `''kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0`'' |
| 215 | + |
| 216 | +- *Creation service*: |
| 217 | + `''kubectl expose deployment hello-server --type=LoadBalancer --port 8080`'' |
| 218 | + |
| 219 | +- *Check svc*: `''kubectl get service`'' |
| 220 | + |
| 221 | +- *To connect*: `''http://[EXTERNAL-IP]:8080'' |
| 222 | + |
| 223 | +- *To clean*: `''gcloud container clusters delete [CLUSTER-NAME]`'' |
| 224 | + |
| 225 | +##### TUTORIAL |
| 226 | + |
| 227 | +[qwiklabs](https://www.qwiklabs.com/) offers tutorials for GCP but |
| 228 | +beware some (almost all) require credits which are paid but can be |
| 229 | +obtained on the internet with some free code offering some credit. |
| 230 | +During these tutorials have a **GCP** account for a time |
| 231 | +determined by a counter which defines the time necessary to do this |
| 232 | +tutorial. |
| 233 | + |
| 234 | +Or other tutorial can be found on |
| 235 | +[cloud.google.com](https://cloud.google.com). |
| 236 | + |
| 237 | +### **Kompose** a way to obtain .yaml files |
| 238 | + |
| 239 | +To create a **KUBERNETES** .yaml files are necessary and in order |
| 240 | +to make life easier there is a way set up by Kubernetes to transform a |
| 241 | +.yml file in .yaml and it is **Kompose**. |
| 242 | + |
| 243 | +Kompose is a tool for converting everything that composes (notably |
| 244 | +Docker Compose) into container orchestrators (Kubernetes or OpenShift). |
| 245 | +More information can be found on the [Kompose](http://kompose.io) |
| 246 | +website. |
| 247 | + |
| 248 | +Here are the commands to follow in order to reach our end: |
| 249 | + |
| 250 | +First go to the directory containing the file “docker-compose.yml”. |
| 251 | + |
| 252 | +then launch the command: `''kompose up`'' (If more than one |
| 253 | +docker-compose there is a possibility to do this: |
| 254 | +`''kompose --file ./examples/docker-compose.yml up`" **beware a |
| 255 | +running Kubernetes cluster with pre-configured kubectl must be |
| 256 | +available.** And only deployments and services are generated and |
| 257 | +deployed in Kubernetes. If need other types of resources, use commands |
| 258 | +`''kompose convert`'' and `''kubectl apply -f`'' instead. If problem type: |
| 259 | +`'' FATA Error while deploying application: Get https://127.0.0.1 : 6443 / api: dial tcp 127.0.0.1:6443: connect: connection refused` |
| 260 | +'' add after **up** --server followed by the address of the |
| 261 | +kubernetes cluster give by `''kubectl cluster-info`'') |
| 262 | + |
| 263 | +Now convert the file “docker-compose.yml” into files usable with |
| 264 | +kubectl, launch: `'' kompose --file 'name' convert` '' (will create all |
| 265 | +the files (services, deployment) in .yaml, no need to mention --file |
| 266 | +'name 'if alone in the directory but this command can also make several |
| 267 | +examples: kompose -f docker-compose1.yml -f docker-compose2.yml convert |
| 268 | +**but be careful when several files of docker-compose are provided, |
| 269 | +the configuration is merged**.) |
| 270 | + |
| 271 | +And then `'' kubectl apply -f <output file>` '' (This will correspond to |
| 272 | +the existing deployment applied via kompose up). |
| 273 | + |
| 274 | +Once deployed the application "composed" on Kubernetes, |
| 275 | +`'' kompose down` '' will facilitate the deletion of the application by |
| 276 | +deleting its deployments and services. If need to delete other |
| 277 | +resources, the use of the **kubectl** command will be useful. |
| 278 | + |
| 279 | +Here is some useful link to understand: |
| 280 | + |
| 281 | +[Convert a Docker Compose file to Kubernetes |
| 282 | +resources](https://kubernetes.io/en/docs/tasks/configure-pod-container/translate-compose-kubernetes/) |
| 283 | + |
| 284 | +[To understand the different option for |
| 285 | +labels](https://github.com/kubernetes/kompose/blob/master/docs/user-guide.md) |
| 286 | + |
| 287 | +[tuto |
| 288 | +KOMPOSE](https://www.katacoda.com/courses/kourses/-docker-compose-using-kompose) |
0 commit comments