-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test and Document Airgap Setup for Go #15512
Comments
Golang AirgappedThe way we are going to set up airgapped golang is using golang’s GOPROXY env variable and using Athens [1]. Athens is an "A Go module datastore and proxy” with great configurability that will give us a place to upload our Go modules too. Since Athens is highly configurable, we are going to set it up so that it acts only as a module datastore and not as a proxy. Essentially, we are going to make it so that an admin can upload their Go modules to this datastore and have them available for their teams Go projects, but once they try and access a Go module that is not in the datastore their Go build will fail. Installing AthensTo start we need to configure Athens, which I will be deploying on minikube via a helm chart.
This will deploy a single instance of athens into the athens namespace. The rest of the modifications will be done through the minikube dashboard. When we are at the minikube dashboard we want to modify the The main dashboard in minikube Setting ATHENS_DOWNLOAD_MODE to none Adding an ingress so Athens is accessible to CheNext I'm going to create an ingress so that we have something we can set the GOPROXY env variable to inside of Che. Inside of the athens namespace add this YAML: kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: athens-ingress
namespace: athens
spec:
rules:
- host: athens-athens.192.168.0.0.nip.io # Change me if you would like
http:
paths:
- path: /
backend:
serviceName: athens-athens-proxy
servicePort: 80 This will make athens available at Preloading Athens with Go modulesThe last thing we need to do is load up Athens with all of our modules. To do this find the
This is pre-loading all of our Go modules into the athens disk. To learn more see [3] . Now athens is fully configured so that if a Go module is not in storage it will return a 404 and do nothing, we have an ingress that we can pass as an env variable in a Go devfile, and we have pre-loaded all of the Go modules our project needs. Connecting to Athens from within CheNow everything from now on is Che side! Use this devfile and start a workspace: metadata:
generateName: golang-
projects:
- name: Go-airgap-sample
source:
location: 'https://github.com/JPinkney/Go-airgap-sample.git'
type: git
components:
- id: ms-vscode/go/latest
memoryLimit: 512Mi
type: chePlugin
alias: go-plugin
- mountSources: true
endpoints:
- name: 8080/tcp
port: 8080
memoryLimit: 512Mi
type: dockerimage
alias: go-cli
image: 'quay.io/eclipse/che-golang-1.12:7.7.0'
env:
- value: /tmp/.cache
name: GOCACHE
- value: 'http://athens-athens.192.168.0.0.nip.io'
name: GOPROXY
- id: eclipse/che-theia/next
type: cheEditor
apiVersion: 1.0.0 Then when your che workspace has loaded open up a $ cd Go-airgap-sample/src/sample/
$ GO111MODULE=on
$ go test On the first run you should see output similiar to:
Now if we modify hello.go to add a new import package hello
import "github.com/jpinkney/hello"
import "github.com/google/go-cmp/cmp"
func hello2() string {
return hello.Hello()
}
func main() {
hello2()
fmt.Println(cmp.Diff("Hello World", "Hello Go"))
} and trying to run
We are getting a 404 Not found error because when we set ATHENS_DOWNLOAD_MODE to none, when a Go module is not found in Athens it will just return a 404. [1] - https://github.com/gomods/athens Setup with self signed certificates
This is so we can use the kubernetes secret created in step 2.
Replace ${MY_MINIKUBE_IP} with your minikube ip This is going to create an ingress for athens and use the che-tls secret that we created in step 2 for getting the self signed certificate.
metadata:
generateName: golang-
projects:
- name: Go-airgap-sample
source:
location: 'https://github.com/JPinkney/Go-airgap-sample.git'
type: git
components:
- id: ms-vscode/go/latest
memoryLimit: 512Mi
type: chePlugin
alias: go-plugin
- mountSources: true
endpoints:
- name: 8080/tcp
port: 8080
memoryLimit: 512Mi
type: dockerimage
alias: go-cli
image: 'quay.io/eclipse/che-golang-1.12:7.7.0'
env:
- value: /tmp/.cache
name: GOCACHE
- value: 'https://athens-che.${MY_MINIKUBE_IP}.nip.io'
name: GOPROXY
- id: eclipse/che-theia/next
type: cheEditor
apiVersion: 1.0.0 where MY_MINIKUBE_IP is replaced with your minikube ip.
and you will see an output similiar to:
|
What about self-signed certs? The config above does not use |
Test and document the process of setting up an airgap solution for Go. In particular, configure a workspace based on our default go devfile to work in an air-gapped scenario (i.e. dependencies being fetched from a repository in the company network. No idea if this is even possible.
The text was updated successfully, but these errors were encountered: