PageRenderTime 70ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/user/project/clusters/runbooks/index.md

https://gitlab.com/klml/gitlab-ee
Markdown | 144 lines | 104 code | 40 blank | 0 comment | 0 complexity | 8c3c7e659f7de36f8bd414e1efc400cc MD5 | raw file
  1. ---
  2. stage: Configure
  3. group: Configure
  4. info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
  5. ---
  6. # Runbooks **(FREE)**
  7. Runbooks are a collection of documented procedures that explain how to
  8. carry out a particular process, be it starting, stopping, debugging,
  9. or troubleshooting a particular system.
  10. Using [Jupyter Notebooks](https://jupyter.org/) and the
  11. [Rubix library](https://github.com/Nurtch/rubix),
  12. users can get started writing their own executable runbooks.
  13. Historically, runbooks took the form of a decision tree or a detailed
  14. step-by-step guide depending on the condition or system.
  15. Modern implementations have introduced the concept of an "executable
  16. runbooks", where, along with a well-defined process, operators can execute
  17. pre-written code blocks or database queries against a given environment.
  18. ## Executable Runbooks
  19. > [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/45912) in GitLab 11.4.
  20. The JupyterHub app offered via the GitLab Kubernetes integration now ships
  21. with Nurtch's Rubix library, providing a simple way to create DevOps
  22. runbooks. A sample runbook is provided, showcasing common operations. While
  23. Rubix makes it simple to create common Kubernetes and AWS workflows, you can
  24. also create them manually without Rubix.
  25. <i class="fa fa-youtube-play youtube" aria-hidden="true"></i>
  26. Watch this [video](https://www.youtube.com/watch?v=Q_OqHIIUPjE)
  27. for an overview of how this is accomplished in GitLab!
  28. ## Requirements
  29. To create an executable runbook, you need:
  30. - **Kubernetes** - A Kubernetes cluster is required to deploy the rest of the
  31. applications. The simplest way to get started is to add a cluster using one
  32. of the [GitLab integrations](../add_remove_clusters.md#create-new-cluster).
  33. - **Ingress** - Ingress can provide load balancing, SSL termination, and name-based
  34. virtual hosting. It acts as a web proxy for your applications.
  35. - **JupyterHub** - [JupyterHub](https://jupyterhub.readthedocs.io/) is a multi-user
  36. service for managing notebooks across a team. Jupyter Notebooks provide a
  37. web-based interactive programming environment used for data analysis,
  38. visualization, and machine learning.
  39. ## Nurtch
  40. Nurtch is the company behind the [Rubix library](https://github.com/Nurtch/rubix).
  41. Rubix is an open-source Python library that makes it easy to perform common
  42. DevOps tasks inside Jupyter Notebooks. Tasks such as plotting Cloudwatch metrics
  43. and rolling your ECS/Kubernetes app are simplified down to a couple of lines of
  44. code. See the [Nurtch Documentation](http://docs.nurtch.com/en/latest/) for more
  45. information.
  46. ## Configure an executable runbook with GitLab
  47. Follow this step-by-step guide to configure an executable runbook in GitLab using
  48. the components outlined above and the pre-loaded demo runbook.
  49. 1. Add a Kubernetes cluster to your project by following the steps outlined in
  50. [Create new cluster](../add_remove_clusters.md#create-new-cluster).
  51. 1. Click the **Install** button next to the **Ingress** application to install Ingress.
  52. ![install ingress](img/ingress-install.png)
  53. 1. After Ingress has been installed successfully, click the **Install** button next
  54. to the **JupyterHub** application. You need the **Jupyter Hostname** provided
  55. here in the next step.
  56. ![install JupyterHub](img/jupyterhub-install.png)
  57. 1. After JupyterHub has been installed successfully, open the **Jupyter Hostname**
  58. in your browser. Click the **Sign in with GitLab** button to log in to
  59. JupyterHub and start the server. Authentication is enabled for any user of the
  60. GitLab instance with OAuth2. This button redirects you to a page at GitLab
  61. requesting authorization for JupyterHub to use your GitLab account.
  62. ![authorize Jupyter](img/authorize-jupyter.png)
  63. 1. Click **Authorize**, and GitLab redirects you to the JupyterHub application.
  64. 1. Click **Start My Server** to start the server in a few seconds.
  65. 1. To configure the runbook's access to your GitLab project, you must enter your
  66. [GitLab Access Token](../../../profile/personal_access_tokens.md)
  67. and your Project ID in the **Setup** section of the demo runbook:
  68. 1. Double-click the **DevOps-Runbook-Demo** folder located on the left panel.
  69. ![demo runbook](img/demo-runbook.png)
  70. 1. Double-click the `Nurtch-DevOps-Demo.ipynb` runbook.
  71. ![sample runbook](img/sample-runbook.png)
  72. Jupyter displays the runbook's contents in the right-hand side of the screen.
  73. The **Setup** section displays your `PRIVATE_TOKEN` and your `PROJECT_ID`.
  74. Enter these values, maintaining the single quotes as follows:
  75. ```sql
  76. PRIVATE_TOKEN = '<your_access_token>'
  77. PROJECT_ID = '1234567'
  78. ```
  79. 1. Update the `VARIABLE_NAME` on the last line of this section to match the name of
  80. the variable you're using for your access token. In this example, our variable
  81. name is `PRIVATE_TOKEN`.
  82. ```sql
  83. VARIABLE_VALUE = project.variables.get('PRIVATE_TOKEN').value
  84. ```
  85. 1. To configure the operation of a runbook, create and configure variables.
  86. For this example, we are using the **Run SQL queries in Notebook** section in the
  87. sample runbook to query a PostgreSQL database. The first four lines of the following
  88. code block define the variables that are required for this query to function:
  89. ```sql
  90. %env DB_USER={project.variables.get('DB_USER').value}
  91. %env DB_PASSWORD={project.variables.get('DB_PASSWORD').value}
  92. %env DB_ENDPOINT={project.variables.get('DB_ENDPOINT').value}
  93. %env DB_NAME={project.variables.get('DB_NAME').value}
  94. ```
  95. 1. Navigate to **Settings > CI/CD > Variables** to create
  96. the variables in your project.
  97. ![GitLab variables](img/gitlab-variables.png)
  98. 1. Click **Save variables**.
  99. 1. In Jupyter, click the **Run SQL queries in Notebook** heading, and then click
  100. **Run**. The results are displayed inline as follows:
  101. ![PostgreSQL query](img/postgres-query.png)
  102. You can try other operations, such as running shell scripts or interacting with a
  103. Kubernetes cluster. Visit the
  104. [Nurtch Documentation](http://docs.nurtch.com/) for more information.