Skip to content

IBM Cloud Virtual Server Instance scheduler to power off and power on automatically.

License

Notifications You must be signed in to change notification settings

victorshinya/instance-scheduler

Repository files navigation

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.

About

IBM Cloud Virtual Server Instance scheduler to power off and power on automatically.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published