Skip to content
Snippets Groups Projects
README.md 3.78 KiB
Newer Older
  • Learn to ignore specific revisions
  • Nathan RODET's avatar
    Nathan RODET committed
    # Scaleway Instances Template - Quickstart
    
    Nicolas PERNOUD's avatar
    Nicolas PERNOUD committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    ## How does it work ?
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    The template will provision several resources (including your instances) to the Scaleway cloud provider using Terraform and Gitlab CI.
    After provisioning, configuration of the instances and deployment of the services (Atrium and TTYD) will be done using Cloud-init and bash scripts.
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    > All your information must be stored in Gitlab and passed as variable to Terraform.
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    ### How the deployment is managed ?
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    The whole project is managed by Gitlab using the Gitlab CI. 
    Launching the pipeline will start the deployment of your infrastructure in 3 steps.  
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    **Plan :**
    Terraform will perform a "fake deployment" and initialize everything he needs before deploying.  
    After performing, you will be able to see the plan of the future creation/modification/destruction in the log of the pipeline.
    If the modification could lead to break changes and errors, you must not launch the next step of the pipeline.
    **Creation :**
    Terraform will be applying the exact changes you reviewed in the Plan step.
    **Destruction :**
    Terraform will destroy the resources he managed to create (or manually imported one).
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    ## How can I use it ?
    
    Nathan RODET's avatar
    Nathan RODET committed
    ### Step 0 : Prerequisite
    
    Nathan RODET's avatar
    Nathan RODET committed
    **On The Forge (Gitlab)**, you must have or ask for the right to fork the repository.  
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    **Scaleway** needs you to have credentials to use their services. You must go to [Scaleway API key page](https://console.scaleway.com/iam/api-keys) 
    and create one for your project. Please make sure to add a description starting with `Terraform - <your description>`.  
    
    Nathan Rodet's avatar
    Nathan Rodet committed
    
    
    Nathan RODET's avatar
    Nathan RODET committed
    **The Certificate Authority (CA)** Let's Encrypt needs an email. He will use it to send a notification before the certificate expires to proceed with
    the renewal.  
    
    Nathan RODET's avatar
    Nathan RODET committed
    ### Step 1 : Getting your own repository
    
    Fork the project from [this repository](https://forge.grandlyon.com/systemes-dinformation/alpha/pocs/scaleway-instances-template)
    
    ### Step 2 : Setting up the variables with credentials and others information
    
    Go to the `Settings` menu, `CI/CD` and look for the `Variables` submenu.  
    Once it's done, you will need to create the variable bellow :  
    - **ENVIRONMENT** : Environment of the deployment, contained in domains, subdomains and resources name convention.  
    - **TF_VAR_INSTANCES_COUNT** : Number of instances to create.  
    - **TF_VAR_LETSENCRYPT_EMAIL** : Lets encrypt mail for renewal.  
    - **TF_VAR_PROJECT_DOMAIN** : External domain from Scaleway. (Example : <xxx>.alpha.grandlyon.com)  
    - **TF_VAR_SCW_ACCESS_KEY** : Scaleway Access Key.  
    - **TF_VAR_SCW_PROJECT_ID** : Project ID from your Scaleway project.  
    - **TF_VAR_SCW_SECRET_KEY** : Scaleway Secret Key.  
    - **TF_VAR_USER_PASSWORD** : User password for accessing services and instances.  
    
    ### Step 3 : Every is set up, deployment is coming !
    
    Go the `CI/CD` menu and `Pipelines`.  
    From now, you will need to click on `Run pipeline` with your selected branch.  
    Since you added variables before, you don't need to put any in this step, click `Run Pipeline` again.  
    
    **Checking logs :** You can click on every step to check logs in case of errors or not.  
    **Check plan :** I recommend to always check the plan when you're trying things to do not perform destruction
    on production infrastructure.  
    
    Once plan is done and ok, click the `Apply button` to deploy the infrastructure. Please be sure to click the `Destroy
    button` to destroy the infrastructure when you don't need it anymore.
    
    ### Step 4 : Accessing your services
    
    After deployment, each resource can be accessed though HTTPS, URL depends of the variable you defined before :
    - **TTYD :** https://terminal-<INSTANCE_COUNT>.<ENVIRONMENT>-<INSTANCE_COUNT>.<PROJECT_DOMAIN/
    - **Atrium :** https://<ENVIRONMENT>-<INSTANCE_COUNT>.<PROJECT_DOMAIN>/
    
    **Example :**
    
    Nathan RODET's avatar
    Nathan RODET committed
    - https://terminal-1.rust-1.daag.alpha.grandlyon.com/
    - https://rust-1.daag.alpha.grandlyon.com/