Skip to content

Commit 14732e2

Browse files
authored
Merge pull request #70 from StackVista/STAC-12663
STAC-12663 Add Kubernetes Cluster name to connections (+ VSCode dev container)
2 parents c18f0bc + 076c2cf commit 14732e2

10 files changed

Lines changed: 2104 additions & 105 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
ARG DEBIAN_VERSION=bullseye-slim
2+
ARG DOCKER_VERSION=20.10.2
3+
ARG DOCKER_COMPOSE_VERSION=debian-1.28.4
4+
ARG GOLANG_VERSION=1.15
5+
ARG GOLANGCI_LINT_VERSION=v1.37.1
6+
7+
FROM docker:${DOCKER_VERSION} AS docker-cli
8+
FROM docker/compose:${DOCKER_COMPOSE_VERSION} AS docker-compose
9+
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION} as golangci-lint
10+
11+
FROM golang:latest
12+
13+
# Configure to avoid build warnings and errors as described in official VSCode Remote-Containers extension documentation.
14+
# See https://code.visualstudio.com/docs/remote/containers-advanced#_reducing-dockerfile-build-warnings.
15+
ENV DEBIAN_FRONTEND=noninteractive
16+
# CA certificates
17+
RUN apt-get update -y && \
18+
# CA certificates
19+
apt-get install -y --no-install-recommends ca-certificates && \
20+
# Timezone
21+
apt-get install -y --no-install-recommends tzdata && \
22+
# Setup Git and SSH
23+
apt-get install -y --no-install-recommends git openssh-client && \
24+
# Setup sudo
25+
apt-get install -y --no-install-recommends sudo && \
26+
# Setup shell
27+
apt-get install -y --no-install-recommends zsh nano locales && \
28+
apt-get autoremove -y && \
29+
apt-get clean -y && \
30+
rm -r /var/cache/* /var/lib/apt/lists/*
31+
32+
ARG USERNAME=vscode
33+
ARG USER_UID=1000
34+
ARG USER_GID=1000
35+
36+
ENV TZ=
37+
WORKDIR /home/${USERNAME}
38+
RUN addgroup --gid $USER_GID $USERNAME && \
39+
useradd $USERNAME --shell /bin/sh --uid $USER_UID --gid $USER_GID && \
40+
mkdir -p /etc/sudoers.d && \
41+
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
42+
chmod 0440 /etc/sudoers.d/$USERNAME && \
43+
rm /var/log/faillog /var/log/lastlog
44+
45+
# Setup shell for root and ${USERNAME}
46+
ENTRYPOINT [ "/bin/zsh" ]
47+
48+
ENV EDITOR=nano \
49+
LANG=en_US.UTF-8 \
50+
# MacOS compatibility
51+
TERM=xterm
52+
53+
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \
54+
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
55+
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
56+
locale-gen en_US.UTF-8
57+
58+
RUN usermod --shell /bin/zsh root && \
59+
usermod --shell /bin/zsh ${USERNAME}
60+
61+
COPY --chown=${USER_UID}:${USER_GID} shell/.p10k.zsh shell/.zshrc shell/.welcome.sh /home/${USERNAME}/
62+
63+
RUN ln -s /home/${USERNAME}/.p10k.zsh /root/.p10k.zsh && \
64+
cp /home/${USERNAME}/.zshrc /root/.zshrc && \
65+
cp /home/${USERNAME}/.welcome.sh /root/.welcome.sh && \
66+
sed -i "s/HOMEPATH/home\/${USERNAME}/" /home/${USERNAME}/.zshrc && \
67+
sed -i "s/HOMEPATH/root/" /root/.zshrc
68+
69+
ARG POWERLEVEL10K_VERSION=v1.14.6
70+
71+
RUN git clone --single-branch --depth 1 https://github.com/robbyrussell/oh-my-zsh.git /home/${USERNAME}/.oh-my-zsh && \
72+
git clone --branch ${POWERLEVEL10K_VERSION} --single-branch --depth 1 https://github.com/romkatv/powerlevel10k.git /home/${USERNAME}/.oh-my-zsh/custom/themes/powerlevel10k && \
73+
rm -rf /home/${USERNAME}/.oh-my-zsh/custom/themes/powerlevel10k/.git && \
74+
chown -R ${USERNAME}:${USER_GID} /home/${USERNAME} && \
75+
chmod -R 700 /home/${USERNAME} && \
76+
cp -r /home/${USERNAME}/.oh-my-zsh /root/.oh-my-zsh && \
77+
chown -R root:root /root/.oh-my-zsh
78+
79+
# Docker
80+
COPY --from=docker-cli --chown=${USER_UID}:${USER_GID} /usr/local/bin/docker /usr/local/bin/docker
81+
COPY --from=docker-compose --chown=${USER_UID}:${USER_GID} /usr/local/bin/docker-compose /usr/local/bin/docker-compose
82+
ENV DOCKER_BUILDKIT=1 \
83+
COMPOSE_DOCKER_CLI_BUILD=1
84+
# All possible docker host groups
85+
RUN G102=`getent group 102 | cut -d":" -f 1` && \
86+
G976=`getent group 976 | cut -d":" -f 1` && \
87+
G1000=`getent group 1000 | cut -d":" -f 1` && \
88+
if [ -z $G102 ]; then G102=docker102; addgroup --gid 102 $G102; fi && \
89+
if [ -z $G976 ]; then G976=docker976; addgroup --gid 976 $G976; fi && \
90+
if [ -z $G1000 ]; then G1000=docker1000; addgroup --gid 1000 $G1000; fi && \
91+
addgroup ${USERNAME} $G102 && \
92+
addgroup ${USERNAME} $G976 && \
93+
addgroup ${USERNAME} $G1000
94+
95+
RUN apt-get update -y \
96+
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
97+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed.
98+
&& apt-get -y install git iproute2 procps lsb-release \
99+
# Install Python2.7
100+
&& apt-get install -y python2.7 python-pip unzip \
101+
&& apt-get install -y protobuf-compiler \
102+
&& apt-get autoremove -y \
103+
&& apt-get clean -y \
104+
&& rm -rf /var/lib/apt/lists/*
105+
106+
ENV GOPATH=/go
107+
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
108+
ARG GOPLS_VERSION=v0.6.6
109+
ARG DELVE_VERSION=v1.5.0
110+
ARG GOMODIFYTAGS_VERSION=v1.13.0
111+
ARG GOPLAY_VERSION=v1.0.0
112+
ARG GOTESTS_VERSION=v1.5.3
113+
ARG MOCK_VERSION=v1.5.0
114+
ARG MOCKERY_VERSION=v2.3.0
115+
116+
RUN mkdir -p ${GOPATH}/src/github.com && \
117+
chown -R ${USER_UID}:${USER_GID} ${GOPATH}
118+
119+
USER ${USERNAME}
120+
121+
COPY --from=golangci-lint /usr/bin/golangci-lint ${GOPATH}/bin
122+
RUN go get -v golang.org/x/tools/gopls@${GOPLS_VERSION} 2>&1
123+
RUN go get -v \
124+
# Base Go tools needed for VS code Go extension
125+
golang.org/x/tools/cmd/guru \
126+
golang.org/x/tools/cmd/gorename \
127+
github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION} \
128+
github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest \
129+
github.com/ramya-rao-a/go-outline \
130+
# Extra tools integrating with VS code
131+
github.com/fatih/gomodifytags@${GOMODIFYTAGS_VERSION} \
132+
github.com/haya14busa/goplay/cmd/goplay@${GOPLAY_VERSION} \
133+
github.com/cweill/gotests/...@${GOTESTS_VERSION} \
134+
github.com/davidrjenni/reftools/cmd/fillstruct \
135+
# Terminal tools
136+
github.com/golang/mock/gomock@${MOCK_VERSION} \
137+
github.com/golang/mock/mockgen@${MOCK_VERSION} \
138+
github.com/vektra/mockery/v2/...@${MOCKERY_VERSION} \
139+
2>&1
140+
141+
USER root
142+
143+
# EXTRA TOOLS
144+
# Kubectl
145+
ARG KUBECTL_VERSION=v1.19.4
146+
RUN wget -qO /usr/local/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" && \
147+
chmod 755 /usr/local/bin/kubectl
148+
149+
# Stern
150+
ARG STERN_VERSION=1.11.0
151+
RUN wget -qO /usr/local/bin/stern https://github.com/wercker/stern/releases/download/${STERN_VERSION}/stern_$(uname -s)_amd64 && \
152+
chown ${USER_UID}:${USER_GID} /usr/local/bin/stern && \
153+
chmod 755 /usr/local/bin/stern
154+
155+
# Kubectx and Kubens
156+
ARG KUBECTX_VERSION=v0.9.3
157+
RUN wget -qO- "https://github.com/ahmetb/kubectx/releases/download/${KUBECTX_VERSION}/kubectx_${KUBECTX_VERSION}_$(uname -s)_$(uname -m).tar.gz" | \
158+
tar -xzC /usr/local/bin kubectx && \
159+
wget -qO- "https://github.com/ahmetb/kubectx/releases/download/${KUBECTX_VERSION}/kubens_${KUBECTX_VERSION}_$(uname -s)_$(uname -m).tar.gz" | \
160+
tar -xzC /usr/local/bin kubens && \
161+
chmod 755 /usr/local/bin/kube*
162+
163+
# Helm
164+
ARG HELM3_VERSION=v3.5.2
165+
RUN wget -qO- "https://get.helm.sh/helm-${HELM3_VERSION}-linux-amd64.tar.gz" | \
166+
tar -xzC /usr/local/bin --strip-components=1 linux-amd64/helm && \
167+
chmod 755 /usr/local/bin/helm*
168+
169+
# AWS CLI
170+
RUN wget -qO awscli2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
171+
unzip awscli2.zip && \
172+
./aws/install && \
173+
rm awscli2.zip
174+
175+
176+
# Revert configurations that was set at top layer (for avoiding build warnings and errors).
177+
ENV DEBIAN_FRONTEND=dialog
178+
179+
USER ${USERNAME}
180+
181+
# Expose service ports.
182+
EXPOSE 8000
183+

.devcontainer/config/kubeconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v1
2+
clusters:
3+
- cluster:
4+
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJd01EVXhNakE1TURRMU9Wb1hEVE13TURVeE1EQTVNRFExT1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTlpXCkhXeGNPMnRqazVoYm1VbURZNGlPcjZGVHNJUEV5NmRaQ29jK2o3NU14OGVOZFp3RlRBaGFTWXZTb3BlRU9PUzQKMEZWRmp2amVNRlhxNkljeFFSUkU3eGwxY2ZXUktGUlNheXZRSlVvdGU0Q3JuOXpPb1Jzc2hDTEZGWWw4bWlGOApDOTZia01YbnZNbkZZYWRxWHlxckNaTmpOYmxXM0JRd09JSGlCNlFIa0czdTJMTTRFOWg5a2dLSUlSeVBrTUdNCmdTdG5PM0hGaEE5UlFkRXlnK2h0VUJhWFJ5S1M4UDVoVUR1Y0VBazc2anh0QmxGWTJVWkFXdGQ1Q2dRUUZyaUgKZ0hEYjJQc01JOWRlck5pQVo4dGU1SWdERElOM1NjS21YQjhQWHhNYXhibFJqQmV6UEdkaWJuZlRkWHprZVhFRgplZVlWUHJzZ1VsS3U2NFF5TEVzQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFEeStMRVpqMVUybWY0ZndaZHZRK2l2TjB5bHMKKzVBMUViVkxEbjhweHN5aTdvWEdMVFhqeWhDd3dqN0NiMFlyUjhhanRxcDVEeEk5UXNZM3NGQUNCbXRGY0xZdgpCRGt3QmpoWXVTK2ZBcHplS2ZadmJDYThuM3VzNWFYaXJSNi96UEVXWmFPUmxXcXBZcXh0eHBYdEtveHUrMDdJCnF0cEpDeEpzdEl3Q3J2M3o2Nm0raUQ1RjY3aDZQV2RiamI1a3dOVDFGR09FbFFtRUdMdXphaXY1NW1mRXA1L3kKb2dXUTlicVlFOFh1VWl1dEVkTmNQbU1xWWhDL1ZVenE1dnVqYnlvUWZ3RExpbTNtUTBRN2UwUHZOZlZyZlVBQgpaSHJPRzNnZXA1TE51UGNQL25jSjBUVDY5NzBGUmpsMnBJVEZGT1hVMFlvb0hNRm0yS3V4VzV6czQ0ND0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
5+
server: https://626E884C4DD680CC3C394E4FA07BD39E.sk1.eu-west-1.eks.amazonaws.com
6+
name: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
7+
contexts:
8+
- context:
9+
cluster: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
10+
user: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
11+
name: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
12+
current-context: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
13+
kind: Config
14+
preferences: {}
15+
users:
16+
- name: arn:aws:eks:eu-west-1:672574731473:cluster/molecule_k8s_test-cluster
17+
user:
18+
exec:
19+
apiVersion: client.authentication.k8s.io/v1alpha1
20+
args:
21+
- --region
22+
- eu-west-1
23+
- eks
24+
- get-token
25+
- --cluster-name
26+
- molecule_k8s_test-cluster
27+
command: aws

.devcontainer/devcontainer.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"name": "StackState Process Agent",
3+
"dockerFile": "Dockerfile",
4+
"extensions": [
5+
"golang.go",
6+
"ms-python.python",
7+
"ms-azuretools.vscode-docker",
8+
"eamodio.gitlens",
9+
"github.vscode-pull-request-github",
10+
"redhat.vscode-yaml",
11+
"ms-kubernetes-tools.vscode-kubernetes-tools",
12+
"shardulm94.trailing-spaces", // Show trailing spaces
13+
"Gruntfuggly.todo-tree", // Highlights TODO comments
14+
"ms-python.vscode-pylance",
15+
"zxh404.vscode-proto3",
16+
],
17+
"containerEnv": {
18+
"GO111MODULE": "off",
19+
"GOMOD": "",
20+
},
21+
"remoteEnv": {
22+
"PATH": "${containerEnv:PATH}:/home/vscode/.local/bin",
23+
"VENV_BASE_PATH": "/home/vscode/.venv",
24+
},
25+
"workspaceMount": "src=${localWorkspaceFolder}/..,dst=/go/src/github.com/StackVista,type=bind",
26+
"workspaceFolder": "/go/src/github.com/StackVista/stackstate-process-agent",
27+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
28+
"settings": {
29+
"go.buildTags": "linux,linux_bpf",
30+
"go.testFlags": [
31+
"-v"
32+
],
33+
"go.useLanguageServer": true,
34+
"[go]": {
35+
"editor.formatOnSave": true,
36+
"editor.codeActionsOnSave": {
37+
"source.organizeImports": true,
38+
},
39+
// Optional: Disable snippets, as they conflict with completion ranking.
40+
"editor.snippetSuggestions": "none"
41+
},
42+
"[go.mod]": {
43+
"editor.formatOnSave": true,
44+
"editor.codeActionsOnSave": {
45+
"source.organizeImports": true,
46+
},
47+
},
48+
"go.autocompleteUnimportedPackages": true,
49+
"go.gotoSymbol.includeImports": true,
50+
"go.gotoSymbol.includeGoroot": true,
51+
"go.buildOnSave": "workspace",
52+
"go.lintOnSave": "workspace",
53+
"go.vetOnSave": "workspace",
54+
"editor.formatOnSave": true,
55+
"go.coverOnSingleTest": true,
56+
"go.coverOnSingleTestFile": true,
57+
"python.pythonPath": "/usr/bin/python",
58+
"git.ignoreLimitWarning": true,
59+
"files.exclude": {
60+
"**/.git": true,
61+
"**/.svn": true,
62+
"**/.hg": true,
63+
"**/CVS": true,
64+
"**/.DS_Store": true,
65+
"vendor": true,
66+
"venv": true,
67+
".vendor-new": true,
68+
".metals": true
69+
},
70+
"todo-tree.highlights.defaultHighlight": {
71+
"icon": "alert",
72+
"type": "text",
73+
"foreground": "red",
74+
},
75+
}
76+
}

.devcontainer/postCreateCommand.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
go get github.com/golang/dep/cmd/dep
4+
go get github.com/awalterschulze/goderive
5+
dep ensure -v -vendor-only
6+
go generate ./...
7+
8+
(cd vendor/github.com/gogo/protobuf && make install)

0 commit comments

Comments
 (0)