Byte-Sized Tech Tips Round-Up: Week 6
Published: 2020-11-14 05:13:15

## Tip 1: Use `skaffold` to test your code quickly

> From
> {% user lidderupk %}

Want to quickly test your Kubernetes service in a cluster, but don’t have the CI/CD set up or don't want to wait for pipelines to deploy your code? I use [`skaffold`](https://skaffold.dev/) when developing locally while deploying to a cluster. It's easy to use in just a few steps!

#### 1. Install skaffold

Get it from [here](https://skaffold.dev/docs/install/).

#### 2. Create a `skaffold.yaml` file.

I use something called [`profiles`](https://skaffold.dev/docs/environment/profiles/) for testing, integration and production environments. Well maybe not production. That should always be CI/CD and maybe even a manual push (up for debate). Here is an example skaffold file with helm. You don’t have to use helm in order to use skaffold:

```yaml
apiVersion: skaffold/v2beta6
kind: Config
profiles:
  - name: test
    activation:
      - command: test
    build:
      artifacts:
      - image: <namespace>/<cluster>/rulesdecision
    deploy:
      helm:
        releases:
        - name: rulesdecision
          chartPath: chart/rulesdecision
          artifactOverrides:
            rulesdecision:
              image:
                repository: <namespace>/<cluster>/rulesdecision
          overrides:
            rulesdecision:
              namespace: test
```

#### 3. Run `skaffold -p deploy`

That’s it! Skaffold will automatically create a new image, load it to your repository and deploy the build on the cluster. It then refreshes the deployment with a new image when you make changes and save. The whole process is like deploying locally, but you are deploying to a cluster. How cool is that! Big caveat is that the deployment artifact will be removed when you quit the `skaffold` command.

## Tip 2: Give your Discord bot a *voice*

> From
> {% user blumareks %} 

This week I was able to configure a bot with a voice channel on a Discord server.

You start by installing [`discord.js`](https://www.npmjs.com/package/discord.js) with `npm`:

```bash
npm install discord.js @discordjs/opus
```

The next step is to create an `index.js` file.

```javascript
const Discord = require('discord.js');
const client = new Discord.Client();
const Token = "<YOUR-BOT-TOKEN>";
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', async message => {
  // Join the same voice channel of the author of the message
  if (message.member.voice.channel) {
    const connection = await message.member.voice.channel.join();
    if (message.content === 'ping') {
      const dispatcher = connection.play('https://cdn.glitch.com/60a14f49-0846-4bad-b84a-e5f018c2130d%2Fmsn_alert.mp3?1506640405402');
      // you can change the volume like this:
      // connection.play('https://...', { volume: 0.1 });
      dispatcher.on('start', () => {
        console.log('audio is now playing!');
      })
        .catch(err => {
          console.log('error:', err);
        });
    }
  }
})

// Always remember to handle errors appropriately!
//dispatcher.destroy();
//Leave voice channel
//connection.disconnect();
client.login(Token);
```

And after creating this file simply type:

```bash
node index.js
```

Now just join a Discord voice channel and write `ping` in one of the text channels and your bot will play a nice welcome tune.

If you want to learn more about bots on Discord see my [blog](https://medium.com/voice-tech-podcast/yeah-a-discord-ai-powered-bot-baby-d9cb73b4775d) and watch the [webinar recording](https://www.crowdcast.io/e/discord-chatbot-with-ibm-3)

## Tip 3: New IBM DataStage blogs and labs

> From
> {% user stevemar %} 

This week and last I've had to dig into the product "IBM DataStage" for a workshop with a client. I used to depend on existing material and a VM based image to get an environment up and running. I decided to learn how to install the product myself and create some supplemental material.

* [Blog about installing DataStage manually](https://www.stevemar.net/installing-datastage/)
* [Blog about using Ansible to install DataStage](https://www.stevemar.net/datastage-playbook/)
* [Lab about reading JSON data from a REST call](https://github.com/IBM/datastage-standalone-workshop/blob/master/workshop/lab-rest/README.md)
* [Lab about configuring a Git server](https://github.com/IBM/datastage-standalone-workshop/blob/master/workshop/lab-git/README.md)