DEV Community

loading...
IBM Developer

Byte-Sized Tech Tips Round-Up: Week 6

Steve Martinelli
Canadian | IBMer | FOSS | Python | Kubernetes
・3 min read

Tip 1: Use skaffold to test your code quickly

From

lidderupk image

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 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.

2. Create a skaffold.yaml file.

I use something called 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:

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
Enter fullscreen mode Exit fullscreen mode

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

blumareks image

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

You start by installing discord.js with npm:

npm install discord.js @discordjs/opus
Enter fullscreen mode Exit fullscreen mode

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

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);
Enter fullscreen mode Exit fullscreen mode

And after creating this file simply type:

node index.js
Enter fullscreen mode Exit fullscreen mode

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 and watch the webinar recording

Tip 3: New IBM DataStage blogs and labs

From

stevemar image

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.

Discussion (0)