### Get Example Go Application Info Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Retrieves information about the deployed 'example-go' application, including its access URL. This command helps in verifying the deployment and accessing the running application. ```bash tsuru app info -a example-go ``` -------------------------------- ### Create and Deploy Example Go Application Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Sets up a local directory, clones example Go application code, creates a 'example-go' app in Tsuru, and deploys the application. This is for testing Tsuru's Go platform. ```bash mkdir example-go cd example-go git clone https://github.com/tsuru/platforms.git cd platforms/examples/go tsuru app create example-go go tsuru app deploy -a example-go . ``` -------------------------------- ### Dockerfile Example for Golang App Deployment Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_using_dockerfile.md This set of code snippets demonstrates a typical setup for deploying a Golang application using a Dockerfile with Tsuru. It includes the Dockerfile itself, the main Go program, the Go module definition, and a Tsuru configuration file. ```dockerfile FROM golang:1.19-alpine WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY *.go . RUN CGO_ENABLED=0 GOOS=linux go build -o /app/main . CMD ["/app/main"] ``` ```golang package main import ( "fmt" "net/http" ) func helloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello from Tsuru!") } func main() { http.HandleFunc("/", helloHandler) port := "8080" fmt.Printf("Server starting on port %s\n", port) http.ListenAndServe(":"+port, nil) } ``` ```gomod module example.com/my-app go 1.19 ``` ```yaml apiVersion: v1 kind: App name: my-example-app platform: docker ``` -------------------------------- ### Start Local Kubernetes Cluster with Minikube Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md This command initiates a local Kubernetes cluster using minikube with a specified Kubernetes version. Ensure minikube and kubectl are installed beforehand. ```bash minikube start —-kubernetes-version=v1.24.0 ``` -------------------------------- ### HTTP Request Example for Listing Available Plans Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Shows an example HTTP GET request to retrieve the list of available service plans. This is typically called when a user runs 'tsuru service-info'. ```http GET /resources/plans HTTP/1.1 Host: myserviceapi.com Accept: application/json Authorization: Basic dXNlcjpwYXNzd29yZA== ``` -------------------------------- ### YAML Configuration Example Source: https://github.com/tsuru/docs/blob/main/src/reference/config.md Illustrates the nested structure of tsuru.conf using YAML syntax. The example shows how 'key1:key2' notation translates to nested key-value pairs in YAML. ```yaml database: url: ``` -------------------------------- ### Install a Tsuru Platform Source: https://github.com/tsuru/docs/blob/main/src/admin_guides/managing_platforms.md Installs a pre-defined platform in Tsuru. This command fetches and sets up the specified platform, making it available for application deployments. It requires the platform name as an argument. ```bash tsuru platform add python ``` -------------------------------- ### Install Tsuru CLI Client Source: https://context7.com/tsuru/docs/llms.txt Installs the Tsuru CLI client for interacting with the Tsuru platform. Supports Debian/Ubuntu, RHEL/Fedora/CentOS, macOS via Homebrew, and Docker. ```bash # Debian/Ubuntu curl -fsSL https://packagecloud.io/install/repositories/tsuru/stable/script.deb.sh | sudo bash sudo apt-get install tsuru-client # RHEL/Fedora/CentOS curl -fsSL https://packagecloud.io/install/repositories/tsuru/stable/script.rpm.sh | sudo bash sudo yum install tsuru-client # macOS with Homebrew brew tap tsuru/homebrew-tsuru brew install tsuru # Docker (for CI/CD pipelines) docker run -t tsuru/client:latest tsuru version # Verify installation tsuru version # Output: Client version: X.Y.Z ``` -------------------------------- ### Install Tsuru Plugin using CLI Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_plugin_install.md This snippet demonstrates the command-line interface usage for installing a Tsuru plugin. It requires the plugin name and URL as arguments. The command downloads the plugin file and places it in the '$HOME/.tsuru/plugins' directory. Options like '--target' and '--verbosity' can be used for server endpoint and logging. ```bash tsuru plugin install [flags] # Example with flags: tsuru plugin install myplugin http://example.com/myplugin.tar.gz --target https://tsuru.example.com --verbosity 2 ``` -------------------------------- ### Procfile Syntax Example Source: https://github.com/tsuru/docs/blob/main/src/user_guides/procfile.md Demonstrates the basic syntax of a Procfile, defining a single process with a name and its corresponding shell command. ```bash web: gunicorn -w 3 wsgi ``` -------------------------------- ### Install Flask Dependency Source: https://github.com/tsuru/docs/blob/main/src/services/build.md Installs the Flask framework, a prerequisite for building the minimal Flask application for the tsuru service API. This command-line instruction is essential for setting up the development environment. ```bash pip install flask ``` -------------------------------- ### Helm Installation on GKE (Bash & kubectl) Source: https://context7.com/tsuru/docs/llms.txt Bash commands to install Tsuru on Google Kubernetes Engine using Helm. Includes creating a GKE cluster, adding the Tsuru Helm repository, installing the Tsuru stack, creating an admin user, and configuring the Tsuru client. ```bash # Create GKE cluster gcloud beta container clusters create tsuru-cluster \ --image-type=COS \ --machine-type=e2-standard-4 \ --num-nodes=2 \ --zone=us-central1-a # Add Tsuru Helm repository helm repo add tsuru https://tsuru.github.io/charts # Install Tsuru stack helm install tsuru tsuru/tsuru-stack \ --create-namespace \ --namespace tsuru-system # Create admin user kubectl exec -it -n tsuru-system deploy/tsuru-api -- \ tsurud root user create admin@example.com # Get Tsuru API endpoint export TSURU_HOST=$(kubectl get svc -n tsuru-system tsuru-api \ -o 'jsonpath={.status.loadBalancer.ingress[].ip}') # Configure client tsuru target add gke http://$TSURU_HOST -s tsuru login admin@example.com ``` -------------------------------- ### HTTP Request Example for App Binding to Service Instance Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Shows an example HTTP POST request to bind an application to a service instance. This specific example uses the 'bind-app' endpoint, which is called once per app binding. ```http POST /resources/myinstance/bind-app HTTP/1.1 Host: myserviceapi.com Content-Type: application/x-www-form-urlencoded app-host=myapp.cloud.tsuru.io&app-name=myapp ``` -------------------------------- ### Procfile Configuration Example Source: https://context7.com/tsuru/docs/llms.txt Defines application processes using a Procfile. This file specifies how to run different types of processes, such as web servers, workers, and schedulers. ```Procfile # Procfile - defines how to run application processes # Web process (receives HTTP traffic on $PORT) web: gunicorn -w 4 -b 0.0.0.0:$PORT wsgi:application # Background worker process worker: celery -A myapp worker --loglevel=info # Scheduler process scheduler: celery -A myapp beat --loglevel=info # Custom process metrics: python metrics_exporter.py ``` -------------------------------- ### Node.js Platform Install Script Source: https://github.com/tsuru/docs/blob/main/src/admin_guides/managing_platforms.md An install script for a custom Node.js platform in Tsuru. This script updates package lists, installs git, clones and configures NVM (Node Version Manager), and sets up the user's profile to include NVM. ```bash #!/bin/bash -le SOURCE_DIR=/var/lib/tsuru source ${SOURCE_DIR}/base/rc/config apt-get update apt-get install git -y git clone https://github.com/creationix/nvm.git /etc/nvm cd /etc/nvm && git checkout `git describe --abbrev=0 --tags` cat >> ${HOME}/.profile </bind-app", methods=["POST"]) def bind_app(name): app_host = request.form.get("app-host") envs = {"SOMEVAR": "somevalue"} return json.dumps(envs), 201 @app.route("/resources//bind-app", methods=["DELETE"]) def unbind_app(name): app_host = request.form.get("app-host") return "", 200 @app.route("/resources/", methods=["DELETE"]) def remove_instance(name): return "", 200 @app.route("/resources//bind", methods=["POST", "DELETE"]) def access_control(name): app_host = request.form.get("app-host") unit_host = request.form.get("unit-host") return "", 201 @app.route("/resources//status", methods=["GET"]) def status(name): return "", 204 if __name__ == "__main__": app.run() ``` -------------------------------- ### Clone Tsuru Repository Source: https://github.com/tsuru/docs/blob/main/src/contributing/docker-compose.md Clones the Tsuru source code from GitHub and navigates into the repository's root directory. This is the initial step to start development. ```bash git clone https://github.com/tsuru/tsuru.git cd tsuru ``` -------------------------------- ### Tsuru Server Configuration (YAML) Source: https://context7.com/tsuru/docs/llms.txt Example Tsuru server configuration file (tsuru.conf) covering HTTP/TLS settings, database connection, authentication methods (native, OAuth, SAML), quotas, logging, and router configurations. ```yaml # tsuru.conf - Server configuration # HTTP server settings listen: "0.0.0.0:8080" host: https://tsuru.example.com shutdown-timeout: 600 # TLS configuration use-tls: true tls: listen: "0.0.0.0:8443" cert-file: /etc/tsuru/cert.pem key-file: /etc/tsuru/key.pem auto-reload: interval: 24h # Database configuration database: url: mongodb://mongo.internal:27017 name: tsurudb # Authentication auth: scheme: native # native, oauth, or saml user-registration: true token-expire-days: 7 hash-cost: 10 # OAuth configuration (when using oauth scheme) # auth: # scheme: oauth # oauth: # client-id: your-client-id # client-secret: your-client-secret # auth-url: https://auth.example.com/authorize # token-url: https://auth.example.com/token # info-url: https://auth.example.com/userinfo # scope: openid email profile # Quotas quota: units-per-app: 20 apps-per-user: 10 # Logging debug: false log: file: /var/log/tsuru/api.log use-stderr: true disable-syslog: false # Router configuration routers: ingress-router: default: true type: api api-url: http://kubernetes-router:8080 domain: cloud.example.com ``` -------------------------------- ### Add Build Platforms to Tsuru Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Adds 'python' and 'go' as build platforms to Tsuru. This enables Tsuru to build applications using these languages. ```bash tsuru platform add python tsuru platform add go ``` -------------------------------- ### Manage Application Information and Status with Tsuru CLI Source: https://context7.com/tsuru/docs/llms.txt Commands to view detailed application information, list all applications, start, stop, restart, update settings, and remove applications using the Tsuru CLI. These commands are fundamental for application lifecycle management. ```bash # Get detailed app information tsuru app info -a myapp # Get app info in JSON format tsuru app info -a myapp --json # List all apps tsuru app list # Stop application tsuru app stop -a myapp # Start application tsuru app start -a myapp # Restart application tsuru app restart -a myapp # Update app settings tsuru app update -a myapp \ --description "Updated description" \ --pool new-pool \ --team-owner newteam # Remove application tsuru app remove -a myapp -y ``` -------------------------------- ### Example Additional Instance Info Response (JSON) Source: https://github.com/tsuru/docs/blob/main/src/services/api.md An example of the JSON response format for retrieving additional information about a service instance. The response is an array of objects, where each object contains a 'label' and a 'value'. ```json [ {"label": "my label", "value": "my value"}, {"label": "myLabel2.0", "value": "my value 2.0"} ] ``` -------------------------------- ### Node.js Platform Deploy Script Source: https://github.com/tsuru/docs/blob/main/src/admin_guides/managing_platforms.md A deploy script for a custom Node.js platform in Tsuru. It sources base scripts, sets up NVM, installs the stable Node.js version, links NVM binaries, and runs `npm install --production` if a `package.json` file exists. ```bash #!/bin/bash -le SOURCE_DIR=/var/lib/tsuru source ${SOURCE_DIR}/base/rc/config source ${SOURCE_DIR}/base/deploy export NVM_DIR=${HOME}/.nvm [ ! -e ${NVM_DIR} ] && mkdir -p ${NVM_DIR} . /etc/nvm/nvm.sh nvm install stable rm -f ~/.nvm_bin ln -s $NVM_BIN ~/.nvm_bin if [ -f ${CURRENT_DIR}/package.json ]; then pushd $CURRENT_DIR && npm install --production popd fi ``` -------------------------------- ### Prepare and Run Tsuru Services with Docker Compose Source: https://github.com/tsuru/docs/blob/main/src/contributing/docker-compose.md Sets up Docker Compose for Tsuru execution by configuring network interfaces and generating necessary config files. Then, it starts all Tsuru service components in detached mode. ```bash ./misc/setup-docker-compose.sh source .env docker-compose up -d ``` -------------------------------- ### Create and Deploy Tsuru Dashboard App Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Creates a new application named 'dashboard' in Tsuru and deploys the official Tsuru dashboard image to it. This provides a web UI for managing Tsuru. ```bash tsuru app create dashboard tsuru app deploy -a dashboard --image tsuru/dashboard ``` -------------------------------- ### Configure Tsuru Target and Login Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Adds the local Tsuru API endpoint as a target in the Tsuru CLI and logs in using the configured credentials. This step is crucial for interacting with your Tsuru instance. ```bash tsuru target-add default http://localhost:8080 -s tsuru login ``` -------------------------------- ### List Users with tsuru CLI Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_user_list.md This snippet demonstrates the command-line interface for listing users in tsuru. It supports filtering by user email or role name, with an optional context value for role filtering. The command requires the tsuru CLI to be installed and configured. ```bash tsuru user list [--user/-u useremail] [--role/-r role [-c/--context-value value]] [flags] Options: -u, --user string Filter user by user email -r, --role string Filter user by role -c, --context-value string Filter user by role context value -h, --help help for list Inherited Options: --target string Tsuru server endpoint --verbosity int Verbosity level: 1 => print HTTP requests; 2 => print HTTP requests/responses ``` -------------------------------- ### Configure a Custom Router in Tsuru Source: https://github.com/tsuru/docs/blob/main/src/faq.md Shows an example of how to configure a custom router within the tsuru configuration file. This allows for flexible routing strategies by defining router type and API endpoint. ```yaml routers: my-router: type: api api-url: http://router-api.example.com default: true ``` -------------------------------- ### Go application code example Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_go_apps.md A basic Go web application that handles HTTP requests for the root path and a healthcheck endpoint. It listens on a port defined by the PORT environment variable or defaults to 8888. ```golang package main import ( "fmt" "net/http" "os" ) func main() { http.HandleFunc("/", hello) http.HandleFunc("/healthcheck", healthcheck) port := os.Getenv("PORT") if port == "" { port = "8888" } err := http.ListenAndServe(":" + port, nil) if err != nil { panic(err) } } func hello(res http.ResponseWriter, req *http.Request) { fmt.Fprintln(res, "hello, world!") } func healthcheck(res http.ResponseWriter, req *http.Request) { fmt.Fprintln(res, "WORKING") } ``` -------------------------------- ### tsuru app metadata get Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_app_metadata_get.md Retrieves metadata for an application or job. This command is deprecated and has been replaced by 'tsuru metadata get'. ```APIDOC ## tsuru app metadata get ### Description Retrieves metadata for an application or job. This command is deprecated and has been replaced by "tsuru metadata get". ### Method GET ### Endpoint /apps/{appName}/metadata or /jobs/{jobName}/metadata (This is an inferred endpoint based on the command's function, as the original text does not specify a direct HTTP endpoint) ### Parameters #### Query Parameters - **appName** (string) - Required - The name of the app. - **jobName** (string) - Required - The name of the job. - **json** (boolean) - Optional - Show JSON output. - **target** (string) - Optional - Tsuru server endpoint. - **verbosity** (integer) - Optional - Verbosity level: 1 => print HTTP requests; 2 => print HTTP requests/responses. ### Request Example ```bash tsuru app metadata get -a my-app ``` ### Response #### Success Response (200) - **metadata** (object) - A key-value map of metadata associated with the app or job. #### Response Example ```json { "metadata": { "key1": "value1", "key2": "value2" } } ``` ``` -------------------------------- ### HTTP Request Example for Unbinding App from Service Instance Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Demonstrates an example HTTP DELETE request to unbind an application from a service instance. This example uses the 'bind-app' endpoint for app-level unbinding. ```http DELETE /resources/myinstance/bind-app HTTP/1.1 Host: myserviceapi.com Content-Type: application/x-www-form-urlencoded app-host=myapp.cloud.tsuru.io&app-name=myapp ``` -------------------------------- ### Create Tsuru App Command Syntax Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_app_create.md This snippet shows the command-line syntax for creating a new Tsuru application. It outlines the mandatory arguments and various optional flags that can be used to configure the app during creation, such as platform, plan, router, team, pool, description, and tags. ```bash tsuru app create [platform] [--plan/-p plan name] [--router/-r router name] [--team/-t team owner] [--pool/-o pool name] [--description/-d description] [--tag/-g tag]... [--router-opts key=value]... [flags] ``` -------------------------------- ### Get tsuru app metadata command Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_app_metadata_get.md Retrieves metadata for a specified application or job. This command is deprecated and has been replaced by 'tsuru metadata get'. It accepts application or job names and can output in JSON format. ```bash tsuru app metadata get <-a/--app appname | -j/--job jobname> [flags] ``` -------------------------------- ### Create a New Tsuru Application Source: https://context7.com/tsuru/docs/llms.txt Creates a new application on Tsuru, specifying platform, plan, team, pool, description, and tags. Lists available platforms and plans. ```bash # Create a basic app with Python platform tsuru app create myapp python # Create app with specific plan and team tsuru app create myapp python \ --plan c1m1 \ --team myteam \ --pool production \ --description "My production application" # Create app with tags for organization tsuru app create myapp nodejs \ --tag environment:production \ --tag tier:frontend # Create app with custom router options tsuru app create myapp go \ --router ingress-router \ --router-opts "loadBalancerType=nlb" # List available platforms tsuru platform list # +----------+---------+ # | Platform | Version | # +----------+---------+ # | python | latest | # | nodejs | latest | # | go | latest | # | java | latest | # +----------+---------+ # List available plans tsuru plan list # +------+-----+--------+-----------+---------+ # | Name | CPU | Memory | Default | | # +------+-----+--------+-----------+---------+ # | c1m1 | 1 | 1Gi | true | | # | c2m2 | 2 | 2Gi | false | # +------+-----+--------+-----------+---------+ ``` -------------------------------- ### Configure Command-Based Startup Check in tsuru.yaml Source: https://github.com/tsuru/docs/blob/main/src/user_guides/tsuru_yaml.md Utilize command-based startup checks in tsuru.yaml to verify application readiness by executing a specific command. A successful execution (exit code 0) indicates the application is ready. ```yaml startupcheck: command: ["curl", "-f", "-XPOST", "http://localhost:8888"] ``` -------------------------------- ### Sample Tsuru Configuration Source: https://github.com/tsuru/docs/blob/main/src/reference/config.md A sample configuration file for Tsuru, demonstrating key settings for listening address, debug mode, host, authentication, and database connection. ```yaml listen: "0.0.0.0:8080" debug: true host: http://:8080 auth: user-registration: true scheme: native database: url: :27017 name: tsurudb ``` -------------------------------- ### Tsuru App Create Command Options Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_app_create.md This snippet lists the available options for the 'tsuru app create' command. These options allow customization of the application's properties, including its description, plan, pool, router, tags, and the owning team. ```bash -d, --description string App description -p, --plan string The plan used to create the app -o, --pool string Pool to deploy your app -r, --router string The router used by the app --router-opts key=value Router options -g, --tag string App tag -t, --team string Team owner app -h, --help help for create ``` -------------------------------- ### POST /apps Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_app_create.md Creates a new application on Tsuru. This endpoint allows specifying the application name, platform, plan, router, team, pool, description, tags, and router options. ```APIDOC ## POST /apps ### Description Creates a new application using the given name and platform. The platform is provisioner dependent. To check available platforms, use `tsuru platform list`. To add a platform, use `tsuru platform add`. To create an app, you need to be a member of at least one team. All teams you are a member of will be able to access the app. ### Method POST ### Endpoint /apps ### Parameters #### Query Parameters - **appname** (string) - Required - The name of the application to create. - **platform** (string) - Optional - The name of the platform to be used when creating the app. This defines how tsuru understands and executes your app. If not provided, a default platform may be used. - **plan** (string) - Optional - The plan to be used. The plan specifies computational resource allocation (memory, swap, CPU share). If not provided, the default plan is used. - **router** (string) - Optional - The router to be used. If not provided, the default router is used. - **team** (string) - Optional - The team responsible for the app. Mandatory if the current user belongs to more than one team. - **pool** (string) - Optional - The pool where the app will be deployed. Mandatory if you have more than one pool associated with your teams. - **description** (string) - Optional - A description for the app. - **tag** (string) - Optional - A tag to associate with the app. Multiple tags can be provided. - **router-opts** (key=value) - Optional - Allows passing custom parameters to the router. The key and values depend on the router implementation. ### Request Example ```json { "appname": "my-new-app", "platform": "python", "plan": "my-plan", "team": "my-team", "description": "This is my awesome new app.", "tag": ["production", "web"], "router-opts": { "timeout": "30s" } } ``` ### Response #### Success Response (201 Created) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "App my-new-app created successfully." } ``` ``` -------------------------------- ### Add Tsuru Helm Repository Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Adds the official Tsuru Helm chart repository to your Helm configuration. This allows you to access Tsuru-related charts for installation. ```bash helm repo add tsuru https://tsuru.github.io/charts ``` -------------------------------- ### Initialize Go module Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_go_apps.md Command to initialize a Go module for a project. This creates a go.mod file to manage dependencies. Remember to replace the placeholder repository path with your actual Git repository. ```bash $ go mod init github.com/tsuru/helloworld ``` -------------------------------- ### Create tsuru job with basic parameters Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_job_create.md This snippet demonstrates the basic syntax for creating a tsuru job. It requires the job name, the Docker image to use, and the commands to execute. Optional parameters like plan, schedule, team, pool, description, tags, and manual execution can be specified. ```bash tsuru job create "" [--plan/-p plan name] [--schedule/-s schedule name] [--team/-t team owner] [--pool/-o pool name] [--description/-d description] [--tag/-g tag] [--max-running-time/-m seconds] [--manual bool]... [flags] ``` -------------------------------- ### HTTP Request Example for General Service API Interaction Source: https://github.com/tsuru/docs/blob/main/src/services/api.md A general example of an HTTP POST request to a service API, demonstrating basic authentication and URL-encoded content type for creating a service instance. ```http POST /resources HTTP/1.1 Host: myserviceapi.com User-Agent: Go 1.1 package http Content-Length: 38 Accept: application/json Authorization: Basic dXNlcjpwYXNzd29yZA== Content-Type: application/x-www-form-urlencoded name=myinstance&plan=small&team=myteam ``` -------------------------------- ### JSON Response Example for Service Instance Binding Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Provides an example JSON response received after successfully binding an application to a service instance. This response typically contains environment variables needed by the application. ```json { "MYSQL_HOST": "10.10.10.10", "MYSQL_PORT": 3306, "MYSQL_USER": "ROOT", "MYSQL_PASSWORD": "s3cr3t", "MYSQL_DATABASE_NAME": "myapp" } ``` -------------------------------- ### TSURU_SERVICES JSON Structure Example Source: https://github.com/tsuru/docs/blob/main/src/services/environment_variables.md An example of the JSON structure for the TSURU_SERVICES environment variable. It details how different service types (like mysql, redis, mongodb) and their instances are represented, including their environment-specific connection variables. ```json { "mysql": [ { "instance_name": "mydb", "envs": { "DATABASE_NAME": "mydb", "DATABASE_USER": "mydb", "DATABASE_PASSWORD": "secret", "DATABASE_HOST": "mysql.mycompany.com" } }, { "instance_name": "otherdb", "envs": { "DATABASE_NAME": "otherdb", "DATABASE_USER": "otherdb", "DATABASE_PASSWORD": "secret", "DATABASE_HOST": "mysql.mycompany.com" } } ], "redis": [ { "instance_name": "powerredis", "envs": { "REDIS_HOST": "remote.redis.company.com:6379" } } ], "mongodb": [] } ``` -------------------------------- ### Create a Go application on Tsuru Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_go_apps.md Command to create a new Go application on the Tsuru platform. Requires specifying the application name and platform type. ```bash $ tsuru app create helloworld go ``` -------------------------------- ### HTTP Request Example for Service Instance Update Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Illustrates an example HTTP PUT request to update an existing service instance. This endpoint is optional and allows modification of parameters like description, tags, team, and plan. ```http PUT /resources/mysql_instance HTTP/1.1 Host: myserviceapi.com Content-Type: application/x-www-form-urlencoded description=new-description&tag=tag1&tag=tag2&team=new-team-owner&plan=new-plan ``` -------------------------------- ### Submit Service Manifest (Bash) Source: https://github.com/tsuru/docs/blob/main/src/services/build.md Submits the completed `manifest.yaml` file to Tsuru to create and register a new service. This command requires a valid manifest file as an argument. ```bash $ tsuru service-create manifest.yaml ``` -------------------------------- ### GET /resources/plans Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Retrieves a list of available service plans. This endpoint is called when `tsuru service-info` is executed. ```APIDOC ## GET /resources/plans ### Description Retrieves the list of available service plans. This is typically called by `tsuru service-info`. ### Method GET ### Endpoint /resources/plans ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```http GET /resources/plans HTTP/1.1 Host: myserviceapi.com Accept: application/json Authorization: Basic dXNlcjpwYXNzd29yZA== ``` ### Response #### Success Response (200) - **plans** (array) - A JSON list of available service plans, each with a `name` and `description`. #### Response Example ```json [ {"name": "small", "description": "plan for small instances"}, {"name": "medium", "description": "plan for medium instances"}, {"name": "huge", "description": "plan for huge instances"} ] ``` #### Error Response (500) - **error** (string) - Description of the failure. ``` -------------------------------- ### Procfile for multiple Go processes Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_go_apps.md Procfile format for specifying the entry points for different processes within a Go application deployed on Tsuru. ```bash web: myapp-api worker: myapp-worker ``` -------------------------------- ### List Available Platforms (tsuru platform list) Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_platform_list.md Lists all available platforms that can be used to create new applications. This command can be filtered using flags to display only names or in JSON format. ```bash tsuru platform list [flags] ``` -------------------------------- ### tsuru.yaml for Healthcheck Configuration Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_nodejs_apps.md The tsuru.yaml file is used for Tsuru-specific configurations. This example sets the healthcheck path to '/'. ```yaml healthcheck: path: / ``` -------------------------------- ### Deploy Tsuru Application Source: https://context7.com/tsuru/docs/llms.txt Deploys application code to Tsuru using various methods including source upload, container images, or Dockerfiles. Supports history listing and version management. ```bash # Deploy from current directory (platform build) tsuru app deploy -a myapp . # Deploy specific directory tsuru app deploy -a myapp ./src/ # Deploy specific files (e.g., JAR file) tsuru app deploy -a myapp ./target/app.jar ./Procfile # Deploy with a commit message tsuru app deploy -a myapp . -m "Add user authentication feature" # Deploy using a pre-built container image tsuru app deploy -a myapp --image registry.example.com/mycompany/app:v1.2.3 # Deploy using Dockerfile in current directory tsuru app deploy -a myapp --dockerfile . # Deploy with specific Dockerfile tsuru app deploy -a myapp --dockerfile ./Dockerfile.production ./ # Deploy creating a new version (traffic splitting) tsuru app deploy -a myapp . --new-version # Deploy and override all existing versions tsuru app deploy -a myapp . --override-old-versions # List deployment history tsuru app deploy list -a myapp # +-------------------+----------------------------+-------------+---------+ # | Image | Timestamp | Commit | Version | # +-------------------+----------------------------+-------------+---------+ # | registry/app:v3 | 2024-01-15 10:30:00 | abc1234 | 3 | # | registry/app:v2 | 2024-01-10 14:20:00 | def5678 | 2 | # +-------------------+----------------------------+-------------+---------+ ``` -------------------------------- ### GET /resources//status Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Checks the current status of a service instance. This is used by the `tsuru service-instance-status` CLI command. ```APIDOC ## GET /resources//status ### Description Checks the current status of a service instance. This is used by the `tsuru service-instance-status` CLI command. ### Method GET ### Endpoint `/resources//status` ### Parameters #### Path Parameters - **instance-name** (string) - Required - The name of the instance to check. ### Request Example ```http GET /resources/myinstance/status HTTP/1.1 Host: myserviceapi.com Authorization: Basic dXNlcjpwYXNzd29yZA== ``` ### Response #### Success Responses - **202**: Instance is being provisioned (pending). - **204**: Instance is running and ready. #### Error Responses - **500**: Instance is not running. Include explanation in body. ``` -------------------------------- ### GET /resources/ Source: https://github.com/tsuru/docs/blob/main/src/services/api.md Retrieves additional information about a service instance. This endpoint is optional and used by `tsuru service-info` and `tsuru service-instance-info`. ```APIDOC ## GET /resources/ ### Description Retrieves additional information about a service instance. This endpoint is optional and used by `tsuru service-info` and `tsuru service-instance-info`. ### Method GET ### Endpoint `/resources/` ### Parameters #### Path Parameters - **instance-name** (string) - Required - The name of the instance to get info for. ### Response #### Success Response (200) - Returns a JSON array of objects, where each object has a 'label' and 'value' field. #### Response Example ```json [ {"label": "my label", "value": "my value"}, {"label": "myLabel2.0", "value": "my value 2.0"} ] ``` #### Error Responses - **404**: No extra info available. ``` -------------------------------- ### Block Events using Tsuru CLI Source: https://context7.com/tsuru/docs/llms.txt Adds a block to prevent certain types of events from occurring, typically used for maintenance. This example blocks app deployments. ```bash tsuru event block add "Scheduled maintenance" \ --kind-name app.deploy \ --target-type app ``` -------------------------------- ### Minimal Flask Application for Tsuru Service API Source: https://github.com/tsuru/docs/blob/main/src/services/build.md A basic Flask application that serves as the foundation for a tsuru service API. It includes a root route that returns 'Hello World!' and is set up to run locally. This serves as the entry point for the tsuru provisioning API. ```python from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run() ``` -------------------------------- ### Create Tsuru Team Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Creates a new team named 'admin' within Tsuru. Teams are used for organizing users and resources in Tsuru. ```bash tsuru team create admin ``` -------------------------------- ### Set Environment Variable for Development Dependencies Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_nodejs_apps.md This command sets the NPM_CONFIG_PRODUCTION environment variable to 'false' for the specified application. This ensures that development dependencies are also installed during deployment. ```bash tsuru env set -a myapp NPM_CONFIG_PRODUCTION=false ``` -------------------------------- ### List Platforms with JSON Output (tsuru platform list --json) Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_platform_list.md Displays the list of available platforms in JSON format. This is useful for programmatic consumption of the platform data. ```bash tsuru platform list --json ``` -------------------------------- ### Manage SSL/TLS Certificates (Tsuru CLI) Source: https://context7.com/tsuru/docs/llms.txt Secure your application with SSL/TLS certificates. This section covers setting certificates for domains, listing existing certificates, configuring automatic certificate issuers like Let's Encrypt, and removing certificates. ```bash # Set certificate for a domain tsuru certificate set -a myapp app.example.com \ ./certificate.crt ./private.key # List certificates tsuru certificate list -a myapp # Configure automatic certificate issuer (Let's Encrypt) tsuru certificate issuer set -a myapp letsencrypt # Remove certificate tsuru certificate unset -a myapp app.example.com ``` -------------------------------- ### Port-Forward to Tsuru API and Ingress Controller Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Establishes port-forwarding connections to the Tsuru API and the Nginx ingress controller. This allows local access to Tsuru services and the ingress. ```bash kubectl port-forward --namespace tsuru-system svc/tsuru-api 8080:80 & kubectl port-forward --namespace tsuru-system svc/tsuru-ingress-nginx-controller 8890:80 & ``` -------------------------------- ### Run Remote Command (Non-Interactive) using Tsuru CLI Source: https://context7.com/tsuru/docs/llms.txt Executes a command remotely within an application's container without starting an interactive session. Useful for running scripts or one-off tasks. ```bash tsuru app run "python manage.py migrate" -a myapp ``` -------------------------------- ### Generate Bash Autocompletion Script for tsuru Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_completion_bash.md Generates the autocompletion script for the bash shell. This command relies on the 'bash-completion' package being installed on the system. The output is a script that can be sourced or redirected to a file for permanent loading. ```bash tsuru completion bash ``` -------------------------------- ### Tsuru App Deploy Command with Dockerfile Source: https://github.com/tsuru/docs/blob/main/src/user_guides/deploy_using_dockerfile.md This bash command deploys an application to Tsuru using a specified Dockerfile. The `--dockerfile` argument points to the container file, and subsequent arguments are deployable files that form the build context. This is the primary method for custom runtime deployments. ```bash tsuru app deploy -a \ --dockerfile [--] [DEPLOYABLE FILES...] ``` -------------------------------- ### Manage Service Instances (Tsuru CLI) Source: https://context7.com/tsuru/docs/llms.txt Commands for managing external service instances like databases and caches. This includes listing available services, viewing service plans, creating new instances, binding them to applications, checking status, and removing them. ```bash # List available services tsuru service list # View service plans tsuru service info mysql # Create a new service instance tsuru service instance add mysql mydb small -t myteam # Create with description and tags tsuru service instance add mysql mydb medium \ -t myteam \ -d "Production database" \ -g environment:production # Bind service instance to application tsuru service instance bind mysql mydb -a myapp # Bind without restarting the app tsuru service instance bind mysql mydb -a myapp --no-restart # Check service instance status tsuru service instance status mysql mydb # View service instance info tsuru service instance info mysql mydb # Unbind service from application tsuru service instance unbind mysql mydb -a myapp # Remove service instance tsuru service instance remove mysql mydb -y ``` -------------------------------- ### Listing Available Plans Source: https://github.com/tsuru/docs/blob/main/src/services/build.md This endpoint retrieves a list of available service plans. ```APIDOC ## GET /resources/plans ### Description Retrieves a list of available service plans. ### Method GET ### Endpoint /resources/plans ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **plans** (array) - A list of plan objects, each with 'name' and 'description'. #### Response Example ```json [ {"name": "small", "description": "small instance"}, {"name": "medium", "description": "medium instance"}, {"name": "big", "description": "big instance"}, {"name": "giant", "description": "giant instance"} ] ``` ``` -------------------------------- ### Configure HTTP Startup Check in tsuru.yaml Source: https://github.com/tsuru/docs/blob/main/src/user_guides/tsuru_yaml.md Define HTTP startup checks in tsuru.yaml to ensure an application is ready before routing traffic. These checks are crucial during deployments and scaling events. ```yaml startupcheck: path: /startupcheck scheme: http headers: Host: test.com X-Custom-Header: xxx allowed_failures: 0 interval_seconds: 10 timeout_seconds: 60 deploy_timeout_seconds: 180 ``` -------------------------------- ### tsuru service instance bind Command Usage Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_service_instance_bind.md This snippet shows the command-line syntax for binding a service instance to an application or job. It includes required arguments like service name and instance name, and optional flags for specifying the app or job, and controlling restart behavior. ```bash tsuru service instance bind [-a/--app appname] [-j/--job jobname] [--no-restart] [flags] ``` -------------------------------- ### Create Tsuru Admin User Source: https://github.com/tsuru/docs/blob/main/src/getting_started/install_minikube.md Executes a command within the Tsuru API deployment to create a root administrator user. Remember to replace the placeholder email with your desired admin email. ```bash kubectl exec -it -n tsuru-system deploy/tsuru-api -- tsurud root user create admin@admin.com# CHANGE IT TO YOUR ADMIN USER # ``` -------------------------------- ### tsuru Service Template Command Options Source: https://github.com/tsuru/docs/blob/main/src/tsuru_client/tsuru_service_template e.g.:.md Provides help information for the 'template' subcommand of 'tsuru service'. It outlines available flags and inherited options for configuring the command's behavior. ```bash tsuru service template --help ```