-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devcontainer POC to this project, see DEVCONTAINER.md for general…
… details
- Loading branch information
Showing
9 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM ubuntu:20.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Installations that require additional steps or are not available via apt | ||
# Azure CLI | ||
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash | ||
# TODO: Figure out if we need these | ||
# Docker | ||
# RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh | ||
# Docker Compose | ||
# RUN curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose | ||
|
||
# Make Zsh the default shell | ||
ENV SHELL=/bin/zsh | ||
|
||
# Create a non-root user 'devuser' | ||
RUN useradd -m -s /bin/zsh devuser | ||
|
||
# Set the working directory to home directory of 'devuser' | ||
WORKDIR /home/devuser/src | ||
|
||
# Copy the current directory contents into the container at /home/devuser/src | ||
# Assuming Dockerfile is inside .devcontainer directory | ||
COPY ../. /home/devuser/src | ||
|
||
# Change ownership of the /home/devuser/src directory to 'devuser' | ||
RUN chown -R devuser:devuser /home/devuser/src | ||
|
||
# Switch to the new user 'devuser' | ||
USER devuser | ||
|
||
# Set the command to start Zsh | ||
CMD ["zsh"] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "splunk-otel-collector-chart-dev-container", | ||
"dockerFile": "Dockerfile", | ||
"features": { | ||
"ghcr.io/devcontainers/features/aws-cli:1": {}, | ||
"ghcr.io/devcontainers/features/azure-cli:1": {}, | ||
"ghcr.io/devcontainers/features/common-utils:2": {}, | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"enableNonRootDocker": "true", | ||
"moby": "true" | ||
}, | ||
"ghcr.io/devcontainers/features/git:1": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { | ||
"version": "latest", | ||
"helm": "latest", | ||
"minikube": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": {}, | ||
"ghcr.io/devcontainers/features/python:1": { | ||
"version": "3.11" | ||
}, | ||
"ghcr.io/devcontainers/features/terraform:1": {}, | ||
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { | ||
"packages": [ | ||
"apt-transport-https", | ||
"build-essential", | ||
"ca-certificates", | ||
"curl", | ||
"gnupg", | ||
"jq", | ||
"libbz2-dev", | ||
"libffi-dev", | ||
"liblzma-dev", | ||
"libncurses5-dev", | ||
"libncursesw5-dev", | ||
"libreadline-dev", | ||
"libsqlite3-dev", | ||
"libssl-dev", | ||
"llvm", | ||
"procps", | ||
"python-openssl", | ||
"tk-dev", | ||
"wget", | ||
"xz-utils", | ||
"zsh" | ||
// Add other packages as needed | ||
] | ||
} | ||
// Add other features as needed | ||
}, | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/zsh" | ||
}, | ||
"extensions": [ | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"ms-azuretools.vscode-docker" | ||
], | ||
"forwardPorts": [8080], | ||
"postCreateCommand": "echo 'Devcontainer is ready!'" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Prompt user for the case they want to use | ||
echo "Which case do you want to use?" | ||
echo "1. Splunk Enterprise or Splunk Cloud Platform" | ||
echo "2. Splunk Observability Cloud" | ||
read -p "Enter 1 or 2: " case | ||
|
||
# Initialize the clusterName variable | ||
read -p "Enter clusterName: " clusterName | ||
|
||
# Create the YAML file based on the user's selection | ||
if [ "$case" = "1" ]; then | ||
# Prompt for Splunk Platform parameters | ||
read -p "Enter Splunk Platform token: " token | ||
# You can customize the endpoint or ask users to input it | ||
endpoint="http://localhost:8088/services/collector" | ||
|
||
# Write to the creds.values file | ||
cat << EOF > creds.values | ||
clusterName: $clusterName | ||
splunkPlatform: | ||
token: $token | ||
endpoint: $endpoint | ||
EOF | ||
elif [ "$case" = "2" ]; then | ||
# Prompt for Splunk Observability parameters | ||
read -p "Enter Splunk Observability realm: " realm | ||
read -p "Enter Splunk Observability accessToken: " accessToken | ||
|
||
# Write to the creds.values file | ||
cat << EOF > creds.values | ||
clusterName: $clusterName | ||
splunkObservability: | ||
realm: $realm | ||
accessToken: $accessToken | ||
EOF | ||
else | ||
echo "Invalid selection. Please run the script again." | ||
fi | ||
|
||
echo "Configuration written to creds.values" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
# Splunk Otel Collector Helm Chart Development with DevContainers | ||
|
||
## Prerequisites | ||
|
||
Before starting, ensure you have the following installed: | ||
|
||
- **[Visual Studio Code](https://code.visualstudio.com/download)** - An IDE with powerful development features. | ||
- **[Docker](https://docs.docker.com/engine/install/)** - Essential for running containers and the DevContainer. | ||
- **[Make](https://www.gnu.org/software/make/)** - A build automation tool, used for running defined tasks. | ||
|
||
## Getting Started | ||
|
||
First, install the Visual Studio [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. You can optinonal go over the [tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial) for how to use this extension. | ||
|
||
![dev-containers-extenstion.png](.devcontainer/dev-containers-extension.png) | ||
|
||
Next, clone the repository to your local system: | ||
|
||
```bash | ||
git clone https://github.com/signalfx/splunk-otel-collector-chart.git | ||
``` | ||
|
||
Then, open the repository in Visual Studio Code. You'll be prompted to reopen the project in a container in a pop-up window. Select "Reopen in Container" to start the DevContainer. | ||
|
||
> **_NOTE:_** If you're not automatically prompted to reopen the project in a container, you can manually start the DevContainer by pressing `F1` to open the command palette, typing "Dev-Containers: Reopen Folder in Container", and hitting `Enter`. | ||
## Starting and Working with the DevContainer | ||
|
||
Once your DevContainer is running, you can start developing as if you were working locally. Visual Studio Code's features like IntelliSense, linting, and debugging all work in the DevContainer. | ||
You can also use the [devcontainer-cli](https://code.visualstudio.com/docs/devcontainers/devcontainer-cli) much like you would with other container clis like Docker or Kubernetes. | ||
|
||
### Using Visual Studio Code UI | ||
|
||
![dev-container-command-palette.png](.devcontainer/dev-container-command-palette.png) | ||
|
||
Efficiently manage your DevContainers with Visual Studio Code's Dev Containers command palette: | ||
|
||
- **Attach to Running Container**: Press `F1`, type "Dev Containers: Attach to Running Container", and hit `Enter` to connect to a running container. | ||
- **Clean Up Dev Volumes**: Press `F1`, choose "Dev Containers: Clean Up Dev Volumes" to remove unused Docker volumes for a cleaner system. | ||
- **Clone Repository in Container Volume**: Press `F1`, select "Dev Containers: Clone Repository in Container Volume" to clone a Git repository directly into a named Docker volume. | ||
- **Configure Container Features**: Press `F1`, type "Dev Containers: Configure Container Features" to modify or install additional container features. | ||
- **Explore a Volume in a Dev Container**: Press `F1`, select "Dev Containers: Explore a Volume in a Dev Container" to browse the contents of a Docker volume within a Dev Container. | ||
- **Install Docker**: Press `F1`, choose "Dev Containers: Install Docker" to set up Docker within the container if necessary. | ||
- **Open Workspace in Container**: Press `F1`, type "Dev Containers: Open Workspace in Container" to start working in a containerized development environment. | ||
- **Rebuild Container**: Press `F1`, select "Dev Containers: Rebuild Container" to recreate the container from scratch. | ||
- **Reopen Folder Locally**: Press `F1`, type "Dev Containers: Reopen Folder Locally" to switch back to working on your | ||
|
||
### Using Github Codespaces Web UI | ||
|
||
TODO: Placeholder, see: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers | ||
|
||
### Using Jetbrains Goland UI | ||
|
||
TODO: Placeholder, see: https://www.jetbrains.com/help/go/connect-to-devcontainer.html | ||
|
||
### Using Make Commands | ||
|
||
For those who prefer command-line tools or require scripting capabilities, the following `make` commands can be used to manage the DevContainer: | ||
|
||
#### Building the Devcontainer | ||
|
||
```bash | ||
make docker-devcontainer-build | ||
``` | ||
Builds the project DevContainer as per the `.devcontainer` directory configuration. | ||
|
||
#### Pushing the Devcontainer | ||
|
||
```bash | ||
make docker-devcontainer-push | ||
``` | ||
Pushes the built DevContainer to a registry. | ||
|
||
#### Starting the Devcontainer | ||
|
||
```bash | ||
make devcontainer-build | ||
``` | ||
Prepares the DevContainer for use. | ||
|
||
#### Spinning Up the Devcontainer | ||
|
||
```bash | ||
make devcontainer-up | ||
``` | ||
Starts the DevContainer with settings from `devcontainer.json`. | ||
|
||
#### Executing Commands in the Devcontainer | ||
|
||
```bash | ||
make devcontainer-exec | ||
``` | ||
Executes a command in the DevContainer environment. | ||
|
||
#### Stopping the Devcontainer | ||
|
||
```bash | ||
make devcontainer-stop | ||
``` | ||
Stops and saves the current state of the DevContainer. | ||
|
||
#### Shutting Down the Devcontainer | ||
|
||
```bash | ||
make devcontainer-down | ||
``` | ||
Completely stops and removes the DevContainer. | ||
|
||
#### Building the Devcontainer | ||
```bash | ||
make docker-devcontainer-build | ||
``` | ||
Builds the project DevContainer as per the `.devcontainer` directory configuration. | ||
|
||
#### Pushing the Devcontainer | ||
```bash | ||
make docker-devcontainer-push | ||
``` | ||
Pushes the built DevContainer to a registry. | ||
|
||
#### Starting the Devcontainer | ||
```bash | ||
make devcontainer-build | ||
``` | ||
Prepares the DevContainer for use. | ||
|
||
#### Spinning Up the Devcontainer | ||
```bash | ||
make devcontainer-up | ||
``` | ||
Starts the DevContainer with settings from `devcontainer.json`. | ||
|
||
#### Executing Commands in the Devcontainer | ||
```bash | ||
make devcontainer-exec | ||
``` | ||
Executes a command in the DevContainer environment. | ||
|
||
#### Stopping the Devcontainer | ||
```bash | ||
make devcontainer-stop | ||
``` | ||
Stops and saves the current state of the DevContainer. | ||
|
||
#### Shutting Down the Devcontainer | ||
```bash | ||
make devcontainer-down | ||
``` | ||
Completely stops and removes the DevContainer. | ||
|
||
### Debugging a DevContainer | ||
|
||
Debugging a DevContainer largely depends on the specific issue you're facing. However, here are some general tips: | ||
|
||
1. **Check the Dockerfile and devcontainer.json files:** Make sure there are no syntax errors or invalid configurations. | ||
2. **Check the build logs:** When you build the DevContainer, Visual Studio Code displays logs in the terminal. These logs can provide useful information about any issues. | ||
3. **Check the Docker daemon:** Ensure that Docker is running properly on your system. You can test this by running a simple command like `docker run hello-world`. | ||
4. **Rebuild the DevContainer:** If you've made changes to the Dockerfile or devcontainer.json, you need to rebuild the DevContainer. You can do this using the "Dev Containers: Rebuild Container" command in the command palette. | ||
5. **Check your system resources:** If your system is low on resources (like memory or disk space), it could cause problems when building or running the DevContainer. | ||
|
||
### Recommended Resource Requirements | ||
|
||
For the best performance, we recommend the following minimum system resources for running the DevContainer: | ||
|
||
- **CPU:** 2 cores | ||
- **Memory:** 6 GB | ||
|
||
Please note that these are just recommendations. The actual resources you need could be more or less depending on the specifics of your project. Also, remember that other applications running on your system will also use resources, so make sure to take that into account. | ||
|
||
If you're running Docker Desktop, you can adjust the allocated resources in the Docker Desktop settings. For other Docker installations, the process may vary. | ||
|
||
### TODOS and Possible Upcoming Features | ||
- Steps for how to use Github Codepspaces with the devcontainer | ||
- Steps for how to use Jetbrains (Goland) with the devcontainer | ||
- Create a Githbut workflow to publish a devcontainer to the repository for devs and CI/CD to use | ||
- Steps for how to pair program remotely using a single devcontainer instance | ||
- Steps on how to spin up a chart demo in the Web UI using Github codespaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters