Kubernetes Data Simplicity: Getting Started With K8ssandra
You might have heard about the K8ssandra project and want to start contributing, or maybe you want to start using all of its features.
You might have heard about the K8ssandra project and want to start contributing, or maybe you want to start using all of its features. If you aren’t familiar with K8ssandra (pronounced like “Kate Sandra”), you can read this overview before digging into the developer activities in this post.
In a nutshell, K8ssandra is an open-source distribution of Apache Cassandra™ for Kubernetes, which includes a rich set of trusted open-source services and tooling. K8ssandra comes with handy features that are baked-in and pluggable, which allows for flexible deployment and configuration.
This post walks the K8ssandra developer through various activities for getting set up to run K8ssandra on a local machine while including maintainer tips and tricks. Information and activities are split into four sections as some readers may already have varied foundations existing for Kubernetes development.
The sections include editor and tooling installation, installation and setup of K8ssandra, hands-on exercises, and information shared from K8ssandra maintainers.
Configuring the Development Environment
Let’s set the foundation for a K8ssandra development environment. Where possible, this guide attempts to maintain an operating system agnostic approach. K8ssandra supports the following operating systems for development:
- macOS
- Linux
- Windows 10
Note: For Windows, we recommend using Windows Subsystem for Linux (WSL2) to execute the shell scripts referenced below.
Although K8ssandra is created primarily to run in Kubernetes cloud environments, we’ll focus here on local machine development.
Reference “Requirements for running K8ssandra for development” for details on managing expectations if you are running on a resource-constrained machine.
Development Editor
If you already have a code editor setup supporting Kubernetes development AND have Go installed, feel free to skip this section.
One option available is Visual Studio Code (VS Code) for development on K8ssandra because it is free, open-source, and supports editing all of the artifacts that make up the K8ssandra project. Another great alternative is JetBrains GoLand IDE, which isn’t free for all users but does provide an evaluation/trial period.
VS Code Installation
First, download the VS Code binaries and install the necessary extensions to assist with K8ssandra development.
1. Download VS
Code specific to your operating system.
Note: this guide is based on version 1.54.2.
2. Add a Go
extension to your VS Code editor for editing and compiling Go sources.
To install an extension, navigate to File->Preferences->Extensions in VS Code and
search for “Go”. This guide uses version 0.23.2 (not the nightly build) from
the Go Team at Google.
3. Follow the steps in the Go extension’s documentation, which includes a Download of Go specific to your operating system. Select 1.14+ as a version.
Here is a list of useful VS Code extensions for K8ssandra development. Search for them by name on the VS Code extensions page.
- ms-kubernetes-tools.vscode-kubernetes-tools - develop, deploy, and debug Kubernetes applications
- ipedrazas.kubernetes-snippets - code snippets of Kubernetes for easier development and configuration.
- redhat.vscode-yaml - YAML language support with Kubernetes syntax assistance included.
Once the VS Code editor and Go binaries are installed, let’s make sure you’re ready to pull in the K8ssandra source.
Git and GitHub
If you already have a Git set up and you’ve got a GitHub account, feel free to skip this section.
1. Reference
the following to install Git properly:
About Git
Setup Guide
Basic Guide
2. Reference
information for setting up a GitHub account.
Getting
started with GitHub
Checkpoint
At this point, you should have the following setup & installed:
✔ VS Code (the editor)
✔ Go (the Golang binaries)
✔ Git (a version control system)
✔ GitHub account (for forking and contributing)
See the references listed below for useful information developers use when starting out with the technologies installed above:
- Using VS Code and Github
- A Git cheat sheet
- Go tutorial
Installing and Configuring a Kubernetes and k8ssandra Environment
If you already have a Kubernetes environment setup with K8ssandra, feel free to skip this section.
This 10-minute
quick-start will guide you through the steps to run a basic K8ssandra
deployment in a local Kubernetes environment.
For a more visual and interactive demonstration of setting up K8ssandra, check
out K8ssandra First Touch, a step-by-step 15-minute video.
Now it’s time to learn about the file types contained in the K8ssandra codebase.
Getting Hands-on
Repository
The K8ssandra GitHub repository resides here. Follow these steps to download the current K8ssandra source code:
1. Click on the Fork button (top right corner of the screen).
2. This will fork the K8ssandra to your personal GitHub repository.
3. Using Git, you can now pull the K8ssandra source code and documentation to your local machine. Some developers choose to do this via the GitHub plugin-in in an IDE or from a command line.
Command line example:
Shell
git clone https://github.com/your-github-repo-name/k8ssandra.git
Note: Insert your personal GitHub repository name followed by k8ssandra.git.
If you want to take GitHub to the command line, check out GitHub CLI. It is GitHub’s official command line tool.
Project Composition
K8ssandra is primarily composed of YAML files used for declarative configurations. In fact, many of the YAML files are a collection of Helm charts. Helm is an open-source package management solution for Kubernetes, and its charts are the packaging format used.
In addition to YAML, you will see some .go files in the K8ssandra project. Go within K8ssandra is used for utilities and tests.
K8ssandra’s reference documentation is maintained with languages including HTML, Markdown, and CSS. The artifacts reside under the top-level /docs folder in the K8ssandra repository and are used to generate content for the k8ssandra.io website.
To round out the different file types, there are shell and Python scripts provided for automation of tasks including documentation publishing and assisting the developer with environment setup tasks. The scripts reside under the top-level /scripts folder in the K8ssandra repository. See their README for more information.
The K8ssandra project contains multiple GitHub repositories, with the main repository at k8ssandra/k8ssandra.
The K8ssandra organization page provides a bird’s eye view of the project’s repository. Each repository has a README that will allow you to learn more about the K8ssandra family.
In addition, there are two very important repositories that currently reside outside of the K8ssandra project; they’re provided as optional tooling for the management of Apache Cassandra:
The K8ssandra repository itself has a few important folders to take note of.
- Charts - Helm-based charts, categorized by sub-chart.
- Docs - layouts, content, etc. that drives k8ssandra.io.
Check out the docs readme for more detail.
- Scripts - a collection of useful scripts for working with K8ssandra that you can use or extend. Also included are documentation scripts for K8ssandra docs management.
- Tests - unit, integration, and end-to-end testing for K8ssandra.
Running Tests
The K8ssandra test directory contains subdirectories for managing and executing tests at the unit and integration levels. Let’s run the unit tests as an example. Using the command line, navigate to the K8ssandra project root directory where the Makefile resides.
Issue the command:
Feel free to explore the K8ssandra Makefile for other recipes that can be targeted.
Maintainer Tips and Tricks
The K8ssandra maintainer team has developed a set of common knowledge and best practices that we wanted to share with you. Think of it as a starting point for learning and growing with K8ssandra. This will enable you to become more comfortable with contributing to the project and/or utilizing K8sssandra to deploy your own applications.
Make Testing a Priority
The K8ssandra maintainers have created test foundations for unit and integration tests with the goal of aligning with Kubernetes developer practices. As you continue to customize and/or expand the K8ssandra ecosystem, it’s recommended to include verifications at all levels.
The K8ssandra project creates separation between the tests themselves and the supporting test data. The illustration below shows sample unit tests written in Go, with their supporting test data files.
Unit Test Artifacts With Test Data Files
Watch for the expansion of testing practices as K8ssandra continues to grow!
Visually Inspect Your Kubernetes Environment
For a more visual way to obtain an overview of the resources and components in a Kubernetes cluster, consider using a free Kubernetes IDE like Lens.
Here’s an example of what it looks like to view your K8ssandra pods, deployments, jobs, and other Kubernetes objects using the Lens UI. The tool has support for Windows, Linux, and macOS.
A UI can be great for some users, but there will be times when only a command line will be required or needed. That’s why tips related to Kubernetes command-line usage specific to K8ssandra are included below.
Commands To Collect Useful Information
If you have an error after editing a K8ssandra configuration, or you just want to inspect resources as you learn, there are many useful commands that can save you lots of time.
The tips are written to use the k8ssandra namespace, but this can be easily adjusted as needed for your own usage.
The shorthand -n is used in the examples in place of the full --namespace designation.
Note: it is possible you may experience a “missing
in charts/ directory” error message when issuing some of the commands. To
prevent this error, utilize the K8ssandra script ./scripts/update-helm-deps.sh
. The script
assists with ensuring charts are updated in the appropriate order.
Let’s get started with some useful commands for looking at important K8ssandra logs.
Log related commands
➠ View Management-api logs. Replace Cassandra-pod with an actual pod instance name.
Summing Up
We’ve covered a lot in this post, including:
- Installing an editor supporting K8ssandra development
- Installing the Go and Git binaries needed for K8ssandra development
- Setting up a GitHub account and forking the K8ssandra repository
- An overview of the project structure and K8ssandra file types
- Running K8ssandra unit tests
- Tips and tricks from K8ssandra maintainers
Completing the activities and understanding the information in this article prepare you to be productive doing K8ssandra development on your local machine. It will also provide you with a foundation for understanding upcoming K8ssandra deep dives.
There are additional open source repositories that make up the overall K8ssandra project. They all contribute to the overall functionality provided by K8ssandra. For more exploration, the primary repositories include:
Next Steps
Here are some recommended next steps for learning more about K8ssandra:
- Examine the roadmap to see where K8ssandra is headed.
- Contribute to K8ssandra; check out this guide to get started.
- Explore K8ssandra deep-dives shared in the official K8ssandra blog, where everyone can learn and share.
- Get to know Apache Cassandra quickly and easily on DataStax Astra DB's free tier.
K8ssandra.io has a wealth of detailed information for digging deeper into the features available. This will assist with making the most of your Cassandra deployments in Kubernetes.
Stay tuned for future K8ssandra articles to expand your knowledge and build on the foundation presented. Feel free to post questions and/or feedback through the following channels:
We Provide consulting, implementation, and management services on DevOps, DevSecOps, Cloud, Automated Ops, Microservices, Infrastructure, and Security
Services offered by us: https://www.zippyops.com/services
Our Products: https://www.zippyops.com/products
Our Solutions: https://www.zippyops.com/solutions
For Demo, videos check out YouTube Playlist: https://www.youtube.com/watch?v=4FYvPooN_Tg&list=PLCJ3JpanNyCfXlHahZhYgJH9-rV6ouPro
If this seems interesting, please email us at [email protected] for a call.
Relevant Blogs:
AWS CDK Project Blueprint - Modeling and Organizing
AWS CDK Project Blueprint - Modeling and Organizing (Part 2/2)
Monitoring Blind Spots in the Cloud and What to Do About Them
Shared Kubernetes Clusters for Hybrid and Multi-Cloud
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post