kubevela.github.io/docs/reference/addons/netlify.md

4.3 KiB

title
netlify

About this workload

  • Netlify is a SaaS platform that can serve website especially for frontend service, it provides free allowances that was pretty cool to be used for demo and test. We can create an addon which provides a netlify component type for frontend service.
  • This workload will launch a K8s job for deploying a fronten service to https://app.netlify.com/.

Quick start

# Properties
+---------------+-----------------------------------------------------------------------------------------------+--------+----------+------------------------------------------------+
|     NAME      |                                          DESCRIPTION                                          |  TYPE  | REQUIRED |                    DEFAULT                     |
+---------------+-----------------------------------------------------------------------------------------------+--------+----------+------------------------------------------------+
| token         | Specify the token got from app.netlify.com                                                    | string | true     |                                              |
| backofflimit  | Specify the backofflimit of the job for deploying the website by netlify                     | int    | true     |                                              |
| completions   | Specify the completions of the job for deploying the website by netlify                      | int    | true     |                                              |
| reponame      | Specify the direcotry name for saving the resources from git or other repo supporting git-cli | string | true     |                                             |
| gitrepo       | Specify the repo address your resources of the frontend service  store                        | string | true     |                                             |
| restartPolicy | Specify the restartPolicy of the job for deploying the website by netlify                     | string | true     |                                             |
| sitname       | Specify the website name on app.netlify.com                                                   | string | true     |                                             |
+---------------+-----------------------------------------------------------------------------------------------+--------+----------+------------------------------------------------+

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: netlify-app
  namespace: default
spec:
  components:
    - name: netlify-comp
      type: netlify
      properties:
        backofflimit: 5
        completions:  1
        reponame: <github reponame>
        gitrepo: <github repo address>
        restartPolicy: OnFailure
        sitename: <sitename>
        token: <Here needs your own token from https://app.netlify.com/user/applications/personal which you should base64 >
  • Check the app status
vela ls netlify-app
APP             COMPONENT       TYPE    TRAITS  PHASE   HEALTHY STATUS  CREATED-TIME                 
netlify-app     netlify-comp    netlify         running healthy         2022-06-14 23:42:43 +0800 CST
vela status netlify-app 
About:

  Name:         netlify-app                  
  Namespace:    default                      
  Created at:   2022-06-14 23:42:43 +0800 CST
  Status:       running                      

Workflow:

  mode: DAG
  finished: true
  Suspend: false
  Terminated: false
  Steps
  - id:k25g896t2o
    name:netlify-comp
    type:apply-component
    phase:succeeded 
    message:

Services:

  - Name: netlify-comp  
    Cluster: local  Namespace: default
    Type: netlify
    Healthy 
    No trait applied	
  • Get the website url for visit
vela logs netlify-app -n default | grep "Website URL"
netlify-comp--1-b4fcg netlify-comp 2022-06-14T15:43:30.641036980Z Website URL:       https://deploy-from-vela.netlify.app