DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • What Is API-First?
  • Commonly Occurring Errors in Microsoft Graph Integrations and How To Troubleshoot Them (Part 4)
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 1

Trending

  • Microservices: Externalized Configuration
  • Optimizing Databricks Spark Pipelines Using Declarative Patterns
  • YOLOv5 PyTorch Tutorial
  • Design Patterns for GenAI Creative Systems in Advertising
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Integrate Walrus CLI With CI/CD Tools to Deploy the 2048 Game

Integrate Walrus CLI With CI/CD Tools to Deploy the 2048 Game

Walrus seamlessly integrates with your existing CI/CD pipelines. This tutorial will guide you on integrating the Walrus CLI with your CI/CD tools to deploy the 2048 Game.

By 
Ally Lynn user avatar
Ally Lynn
·
Dec. 16, 23 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
3.4K Views

Join the DZone community and get the full member experience.

Join For Free

Walrus, an open-source application management platform, simplifies the deployment process and seamlessly integrates with your existing CI/CD pipelines. In this tutorial, we will guide you on integrating the Walrus CLI with your CI/CD tools to deploy the 2048 Game. 

Prerequisites

Before you begin, ensure you have the following:

  1. A GitHub repository where you can fork our Demo project.

  2. Walrus installed.

  3. A project set up in Walrus.

  4. Creation of a K8s connector within the project.

  5. An environment established, and the K8s connector added to it.

Let's get started with the integration process!

Generating an API Key

To enable communication between the Walrus CLI and the Walrus server, you'll need to create an API key. Here's how you can do it:

  1. Navigate to your User information  and select API Keys

  2. Click on Add new key, then provide a name for your key and set an expiration time.

  3. Once you've configured the key, make sure to copy the generated key for future use. This key will facilitate the CLI's interaction with the Walrus server.

Integrating Walrus CLI With GitHub Actions

Here, we'll illustrate the integration of the Walrus CLI with GitHub Actions. Follow these steps:

  • Head to your GitHub repository and access the Settings menu. Then, navigate to Security > Secrets and Variables > Actions. Configure your repository secrets with the following variables to securely store sensitive information: CI_REGISTRY_USERNAME, CI_REGISTRY_PASSWORD, CD_WALRUS_SERVER, and CD_WALRUS_TOKEN. For CD_WALRUS_SERVER, ensure the format is https://domain:port/. These secrets will enable secure communication between GitHub Actions and Walrus CLI.

  • Next, in your GitHub repository, create a ci.yaml file under the .github/workflows directory. This file will define your CI/CD workflow.

Here's an example of a ci.yaml file for deploying the 2048 Game. You can copy and customize it according to your specific environment variables and requirements:

Go
 
name: CICD

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CI_REGISTRY: '' # Use Docker Hub when empty
  CI_IMAGE_NAME: sealdemo/game2048
  CD_WALRUS_PROJECT: demo
  CD_WALRUS_PROJECT_ENV: dev
  CD_WALRUS_SERVICE_NAME: game2048
  
jobs:
  delivery:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 8
      uses: actions/setup-java@v3
      with:
        java-version: '8'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      run: mvn -B clean package --file pom.xml
    - name: Docker Login
      uses: docker/[email protected]
      with:
        registry: ${{ env.CI_REGISTRY }}
        username: ${{ secrets.CI_REGISTRY_USERNAME }}
        password: ${{ secrets.CI_REGISTRY_PASSWORD }}
    - name: Build and push Docker image
      run: |
        docker build . --file Dockerfile --tag ${{ env.CI_IMAGE_NAME }}:${{ github.run_id }}
        docker push ${{ env.CI_IMAGE_NAME }}:${{ github.run_id }}
    - name: Download CLI
      run: |
        # Download walrus CLI
        curl -v -k -o walrus -LO "${{ secrets.CD_WALRUS_SERVER }}/cli?arch=amd64&os=linux"
        chmod +x ./walrus
    - name: Deploy
      run: |
        # Setup CLI config
        ./walrus config setup --insecure --server ${{ secrets.CD_WALRUS_SERVER }} --token ${{ secrets.CD_WALRUS_TOKEN }} --project ${{ env.CD_WALRUS_PROJECT }} --environment ${{ env.CD_WALRUS_PROJECT_ENV }}
       
        # Deploy app
        ./walrus service create --debug --name ${{ env.CD_WALRUS_SERVICE_NAME }} --template '{"name": "webservice", "version": "v0.0.2"}' --attributes '{"image": "${{ env.CI_IMAGE_NAME }}:${{ github.run_id }}", "ports": ["8080"]}'

Now, try triggering the workflow execution and checking the results. 

If you encounter any errors during the workflow execution, the first step should be to check your GitHub Actions permissions and configurations to ensure that everything is set up correctly. 

Once the deployment is complete, you can access and view the 2048 Game within Walrus. 

You can access the 2048 Game using the following URL format: http://domain:port/2048/. This confirms that you have successfully integrated the Walrus CLI with your CI/CD tools to deploy the 2048 game.

API GitHub Integration Continuous Integration/Deployment

Published at DZone with permission of Ally Lynn. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • What Is API-First?
  • Commonly Occurring Errors in Microsoft Graph Integrations and How To Troubleshoot Them (Part 4)
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 1

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook