Giter VIP home page Giter VIP logo

instance-scheduler's Introduction

IBM Cloud Instance Scheduler

IBM Cloud Powered Platform Go Report Card LICENSE PRs Welcome

A Serverless function to automatically start and stop IBM Cloud Virtual Server Instances.

Architecture Diagram

Deploy to IBM Cloud

Before you get started, you need to install IBM Cloud CLI and IBM Cloud Functions CLI in your local machine. Then, you need to login in your IBM Cloud account on IBM Cloud CLI (if you haven't already done, run ibmcloud login).

1. Clone the repository

Download the source code from Github and access the project folder.

git clone https://github.com/victorshinya/instance-scheduler.git
cd instance-scheduler

2. Get Username and generate Classic Infrastructure API key

As you can manage your infrastructure using a SDK or API, you have to authenticate with a username and apikey. To get your username for the current account and generate the classic infrastructure API key. Go to Manage > Access (IAM) > Users and click on your name on the list.

Instance Scheduler 01

  1. Scroll down to the VPN password section and copy the Username. This is going to be used on Instance Scheduler.
  2. Scroll down to the API keys section and click on Create classic infrastructure key to automatically generate your API key. Copy the key. You are going to use it with username.

Instance Scheduler 02

3. Set up the environment variables to deploy them as function's parameters

Run the following command with the classic infrastructure username and API key, and the list with all Virtual Servers to power on/off:

  • SOFTLAYER_USERNAME is the Username field that you copied from previous step.
  • SOFTLAYER_APIKEY is the API key, generated in the previous step.
  • VSIS_NAME is the list with all Virtual Servers on Classic IaaS (Softlayer) that you'd like to power on/off - e.g. '["VSI NAME 01", "VSI NAME 02", "SO ON, AND ON"]'.
export SOFTLAYER_USERNAME="" SOFTLAYER_APIKEY="" VSIS_NAME='[""]'

4. Set the time to power off and power on the VSI

In manifest.yml file, it is set (by default) to power off the VSI at 03:00 AM (00:00 AM GMT-3) and to power on the VSI at 09:00 AM (06:00 AM GMT-3). Update if you need to run both actions at the desire hour.

5. Deploy the Action, Triggers and Rules

Run the following command to deploy handler.go function and to set up the Triggers and Rules.

As you are using IBM Cloud Functions, you don't need to install any package or setup a package.json. The platform already has all libraries required to run the source code.

ibmcloud fn deploy --manifest manifest.yml

LICENSE

Copyright 2021 Victor Shinya

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.