NAV

Introduction

Welcome to the official documentation for Konjure – your gateway to streamlined Infrastructure-from-Code transformation! In a world where agility and automation are the cornerstones of modern IT, Konjure stands as your trusted companion for translating code into robust, scalable infrastructure. This documentation is your key to unlocking the full potential of Konjure, where we’ll guide you through every facet of this innovative tool.

Whether you’re a battle-hardened DevOps engineer or a curious developer venturing into the realm of infrastructure automation, Konjure equips you with the tools to effortlessly craft and manage your environment using code. With comprehensive explanations, hands-on tutorials, and real-world use cases, this documentation empowers you to harness the power of Konjure effectively.

Join us on a journey where lines of code metamorphose into concrete infrastructure, where deployment and maintenance become synonymous with simplicity. As we navigate through the intricacies of Konjure together, you’ll discover a new era of IT where efficiency, collaboration, and scalability converge seamlessly. Let’s embark on this transformative experience and pioneer the future of infrastructure, hand in hand with Konjure.

The services Konjure supports

Service Go Java
Kafka
Mongo
PostgreSQL
RabbitMQ
AWS DynamoDB
AWS ECR
AWS Kinesis
AWS S3
AWS SQS
Azure Storage ✅ 
GCP Pubsub
GCP Storage  ✅

Getting Started

Welcome to the Konjure project! Konjure is an open-source command-line interface designed to simplify the process of generating Kubernetes resources’ YAML files for your applications. Whether you’re working with web services, background jobs, or any other kind of application, Konjure helps you streamline the process by analyzing your code repository and generating the necessary Kubernetes resources based on the detected application type and cloud service dependencies.

Installation

To get started with Konjure, you need to install it on your system. Konjure supports macOS, Ubuntu/Debian, and Windows platforms.

If you’re using macOS, you can install Konjure using Homebrew, a popular package manager for macOS:

brew tap hocus-tech/konjure
brew install konjure

For Ubuntu/Debian-based systems, you can install Konjure using APT, the package manager for these distributions:

sudo apt update
sudo apt install konjure

Windows users can use Chocolatey, a package manager for Windows, to install Konjure:

choco install konjure

Configuration

Once Konjure is installed, you need to configure it before you can start generating Kubernetes resources. The configuration process involves providing the necessary inputs for your application and its cloud service dependencies. To configure Konjure, you’ll use the konjure bootstrap command:

konjure bootstrap

This command will guide you through a series of prompts to gather information such as the repository link (GitHub, GitLab), cloud service credentials (AWS, GCP, Azure), and other relevant details about your application.

Generating Kubernetes Resources

With Konjure configured, you’re ready to generate Kubernetes resources’ YAML files for your application. The konjure command is used to trigger the resource generation process:

konjure -dir <dir> -licenseKey <licenseKey> -name <name>
  • dir: the directory of the source code
  • licenseKey: your Konjure license key
  • name: the name of the application

Konjure will analyze the code in the provided repository, determine the type of application (web service, job, etc.), and identify the cloud services used. Based on this analysis, it will generate the necessary Kubernetes resources’ YAML files, tailored to your application’s requirements.

Congratulations! You’ve successfully started using Konjure to automate the generation of Kubernetes resources for your projects. This process can save you time and effort while ensuring that your Kubernetes deployment files are accurate and efficient.

Additional Resources

For more information, you can check out the official Konjure documentation, which provides detailed usage instructions, configuration options, and advanced features: Konjure Documentation

If you encounter any issues, have questions, or want to contribute to the project, feel free to visit the Konjure GitHub repository: Konjure GitHub Repository

Thank you for choosing Konjure, and happy Kubernetes resource generation!

How It Works

Konjure simplifies the process of generating Kubernetes resources’ YAML files by automating the analysis of your codebase and intelligently detecting application types and cloud service dependencies. Here’s a step-by-step overview of how Konjure works:

1. Code Analysis

When you invoke the konjure generate command, Konjure starts by analyzing the code within your repository. It supports multiple programming languages such as Go and Java, and it examines the structure and content of your code to understand how your application works.

Example: Go Code with AWS S3 Integration

Consider a codebase that interacts with AWS S3:

package main

import (
    "fmt"
    "net/http"
    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/s3"
)

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

func handler(w http.ResponseWriter, r *http.Request) {
    sess := session.Must(session.NewSession(&aws.Config{
        Region: aws.String("us-west-1"),
    }))
    
    svc := s3.New(sess)
    bucketName := "my-existing-bucket"
    objectKey := "example.txt"
    
    result, err := svc.GetObject(&s3.GetObjectInput{
        Bucket: aws.String(bucketName),
        Key:    aws.String(objectKey),
    })
    if err != nil {
        fmt.Println("Error getting object:", err)
        return
    }
    
    fmt.Fprintf(w, "Object content: %s", result.Body)
}
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.S3Exception;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpExchange;

public class Main {

    public static void main(String[] args) throws IOException {
        HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
        server.createContext("/", new MyHandler());
        server.setExecutor(null); // Use the default executor
        server.start();
    }

    static class MyHandler implements HttpHandler {
        public void handle(HttpExchange httpExchange) throws IOException {
            S3Client s3 = S3Client.builder()
                    .region(Region.US_WEST_1)
                    .credentialsProvider(DefaultCredentialsProvider.create())
                    .build();

            String bucketName = "my-existing-bucket";
            String objectKey = "example.txt";

            try {
                GetObjectRequest getObjectRequest = GetObjectRequest.builder()
                        .bucket(bucketName)
                        .key(objectKey)
                        .build();

                GetObjectResponse getObjectResponse = s3.getObject(getObjectRequest);
                InputStream objectContent = getObjectResponse.readAllBytes();

                String content = new String(objectContent.readAllBytes(), StandardCharsets.UTF_8);

                String response = "Object content: " + content;
                httpExchange.sendResponseHeaders(200, response.length());
                httpExchange.getResponseBody().write(response.getBytes());
                httpExchange.close();
            } catch (S3Exception e) {
                String response = "Error getting object: " + e.getMessage();
                httpExchange.sendResponseHeaders(500, response.length());
                httpExchange.getResponseBody().write(response.getBytes());
                httpExchange.close();
            }
        }
    }
}

Konjure detects that this codebase is an HTTP server application that interacts with AWS S3.

2. Dependency and Function Detection

Konjure generates a call graph based on the code analysis. It identifies the packages, libraries, and functions that your application uses. This information is crucial for understanding your application’s dependencies and how it interacts with external services.

Example: Detected Dependencies

From the previous Go code example, Konjure detects the use of the net/http package, the fmt package, and the AWS SDK for Go. This indicates that the application is an HTTP server that interacts with AWS S3.

3. YAML Generation

Based on the analyzed code, detected dependencies, and identified cloud service integrations, Konjure generates Kubernetes resources’ YAML files. These files are tailored to your application’s requirements and include deployments, services, pods, and other relevant resources.

Example: Generated YAML files for the example above

Konjure detected that the code example above is an HTTP server application that interacts with AWS S3. Therefore it will generate a deployment and Crossplane Bucket resources(alongside other necessary resources).

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  selector:
    matchLabels:
      app: my-deployment
  replicas: 4
  template:
    metadata:
      labels:
        app: my-deployment
    spec:
      serviceAccountName: my-sa
      containers:
      - name: my-deployment
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
---

apiVersion: s3.aws.crossplane.io/v1beta1
kind: Bucket
metadata:
  name: my-existing-bucket
  annotations:
    crossplane.io/external-name: my-existing-bucket
spec:
  forProvider:
    objectOwnership: BucketOwnerEnforced
    publicAccessBlockConfiguration:
      blockPublicAcls: true
      blockPublicPolicy: true
      ignorePublicAcls: true
      restrictPublicBuckets: true
    serverSideEncryptionConfiguration:
      rules:
      - applyServerSideEncryptionByDefault:
          sseAlgorithm: AES256
        bucketKeyEnabled: true

4. Crossplane and Operators

Konjure embraces a flexible approach to seamlessly integrate various cloud services into your Kubernetes resources. For cloud providers like AWS, GCP, and Azure, Konjure leverages the power of Crossplane. Crossplane is a framework for building cloud native control planes without needing to write code.

When it comes to other specialized services like MongoDB, Apache Kafka, and more, Konjure taps into the capabilities of dedicated Kubernetes Operators. These Operators are specifically designed to extend Kubernetes and manage complex applications and services. By employing Operators tailored to each service, Konjure ensures a robust and efficient integration into your Kubernetes deployment.

This dynamic strategy allows Konjure to cater to a wide spectrum of cloud and service integrations, providing you with a unified experience while creating Kubernetes resources. Whether you’re dealing with well-established cloud providers or specialized services, Konjure’s Crossplane and Operator utilization ensures that your Kubernetes deployment aligns with best practices and efficient infrastructure management.

Conclusion

With Konjure, you no longer need to manually craft Kubernetes resources’ YAML files. By analyzing your codebase, identifying dependencies, detecting cloud service integrations, and utilizing Crossplane for major cloud providers and specialized Operators for other services, Konjure empowers you to automate the creation of Kubernetes resources while maintaining the best practices for infrastructure as code.

Konjure simplifies the process, reduces human error, and accelerates your journey toward deploying reliable and efficient applications on Kubernetes.