Skip to content

Commit

Permalink
Merge pull request #25 from kubeshark/terraform
Browse files Browse the repository at this point in the history
Terraform and TLS demo
  • Loading branch information
alongir committed Jan 14, 2024
2 parents fdee127 + 3a099be commit f933c9b
Show file tree
Hide file tree
Showing 25 changed files with 806 additions and 219 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ jobs:
#
#
#check complete demo is in sync with individual manifest, it should block fom merge. Should this be a diferent file?
complete-demo-sync-check:
runs-on: ubuntu-latest
env:
COMPLETE_DEMO_ARGS: --rm -v ${{ github.workspace }}:/workdir
COMPLETE_DEMO_DIR: 'deploy/kubernetes/'
COMPLETE_DEMO_IMAGE: 'manifests-image'
steps:
- uses: actions/checkout@v2
# complete-demo-sync-check:
# runs-on: ubuntu-latest
# env:
# COMPLETE_DEMO_ARGS: --rm -v ${{ github.workspace }}:/workdir
# COMPLETE_DEMO_DIR: 'deploy/kubernetes/'
# COMPLETE_DEMO_IMAGE: 'manifests-image'
# steps:
# - uses: actions/checkout@v2

#
#
# Build image
- name: Build image
env:
DOCKER_BUILDKIT: 1
run: docker build -t $COMPLETE_DEMO_IMAGE $COMPLETE_DEMO_DIR
# #
# #
# # Build image
# - name: Build image
# env:
# DOCKER_BUILDKIT: 1
# run: docker build -t $COMPLETE_DEMO_IMAGE $COMPLETE_DEMO_DIR

#
#
# Check that manifest and complete-demo.yaml ahve the same content
- name: check comeplte-demo.yaml content sync
run: docker run $COMPLETE_DEMO_ARGS $COMPLETE_DEMO_IMAGE make -C $COMPLETE_DEMO_DIR check-complete-demo
# #
# #
# # Check that manifest and complete-demo.yaml ahve the same content
# - name: check comeplte-demo.yaml content sync
# run: docker run $COMPLETE_DEMO_ARGS $COMPLETE_DEMO_IMAGE make -C $COMPLETE_DEMO_DIR check-complete-demo

#
#
# #
# #
#check that we can deploy complete-demo
#NOTE: what about docker compose? maybe doesn't make sense if we use the KIND action
#NOTE: later we can test that the documentation is tested, as in previous cronjobs in travis
Expand Down
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,44 @@ output-virtualbox-iso
/graphs/*.json

.vscode

# Created by https://www.toptal.com/developers/gitignore/api/terraform
# Edit at https://www.toptal.com/developers/gitignore?templates=terraform

### Terraform ###
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

# End of https://www.toptal.com/developers/gitignore/api/terraform
3 changes: 2 additions & 1 deletion additions/outbound-tls-golang/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

docker build . -t mertyildiran/mizutest-outbound-tls-golang:latest && docker push mertyildiran/mizutest-outbound-tls-golang:latest
# docker build . -t mertyildiran/mizutest-outbound-tls-golang:latest && docker push mertyildiran/mizutest-outbound-tls-golang:latest
docker buildx build --platform linux/amd64 -t alongir/mizutest-outbound-tls-openssl:latest . --push
Binary file added additions/outbound-tls-golang/main
Binary file not shown.
23 changes: 17 additions & 6 deletions additions/outbound-tls-golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ func main() {
req, err := http.NewRequest("GET", "https://gorest.co.in/public/v2/not-found", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

payload := strings.NewReader(fmt.Sprintf("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\njohn.doe.%d@example.com\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nmale\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"status\"\r\n\r\nactive\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", j))
req, err = http.NewRequest("POST", "https://gorest.co.in/public/v2/users", payload)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
req.Header.Set("authorization", fmt.Sprintf("Bearer %s", ACCESS_TOKEN))
Expand All @@ -53,38 +57,45 @@ func main() {
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

req, err = http.NewRequest("GET", "https://gorest.co.in/public/v2/users", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

req, err = http.NewRequest("GET", "https://gorest.co.in/public/v2/posts", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)
_, err = io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
}
// fmt.Printf("body: %v\n", string(body))

time.Sleep(3 * time.Second)
}
}
}
3 changes: 2 additions & 1 deletion additions/outbound-tls-openssl/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

docker build . -t mertyildiran/mizutest-outbound-tls-openssl:latest && docker push mertyildiran/mizutest-outbound-tls-openssl:latest
# docker build . -t mertyildiran/mizutest-outbound-tls-openssl:latest && docker push mertyildiran/mizutest-outbound-tls-openssl:latest
docker buildx build --platform linux/amd64 -t alongir/mizutest-outbound-tls-openssl:latest . --push
18 changes: 10 additions & 8 deletions additions/outbound-tls-openssl/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
j += 1
# print("-----\n%d" % j)

# First request - POST
url = "https://gorest.co.in/public/v2/users"

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\njohn.doe.%d@example.com\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nmale\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"status\"\r\n\r\nactive\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" % j
headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
Expand All @@ -22,36 +22,38 @@

try:
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)

# Second request - GET
url = "https://gorest.co.in/public/v2/users"

headers = {
'cache-control': "no-cache",
'x-powered-by': "openssl",
}

try:
response = requests.request("GET", url, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)

# Third request - GET
url = "https://gorest.co.in/public/v2/posts"

headers = {
'cache-control': "no-cache",
'x-powered-by': "openssl",
}

try:
response = requests.request("GET", url, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)
# Wait for 3 seconds before the next iteration
time.sleep(3)
Binary file added deploy/kubernetes/kubeshark
Binary file not shown.
149 changes: 149 additions & 0 deletions deploy/kubernetes/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f933c9b

Please sign in to comment.