9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/generators/tpt/rails/kubernetes/kubernetes_generator.rb', line 9
def setup_kubernetes
if !valid_app_name?
say("ERROR: App name #{Tpt::Rails.app_name.inspect} will not be valid for DNS usage.")
abort
end
check_dependencies
secrets_name = "#{Tpt::Rails.app_name}-secrets"
secrets_key = "secret-key-base"
secrets_value = SecureRandom.alphanumeric(32).downcase
team_name = ask("What's your GitHub team name? Something like `core-services`").strip
app_type = "internal"
tpt_config = get_tpt_config
tpt_user_alias = tpt_config.fetch('user.alias')
template 'Dockerfile'
template 'entrypoint.sh'
template '.dockerignore'
directory(
'kubernetes',
team_name: team_name,
secrets_name: secrets_name,
secrets_key: secrets_key,
app_type: app_type,
)
inside('kubernetes/helm') do
run('helm dependency update', abort_on_failure: true)
end
add_kube_secret(secrets_name, secrets_key, secrets_value)
say(<<~MESSAGE)
********************************************************************************
* Success! Your project has been configured for Kubernetes!
********************************************************************************
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Follow-up actions required:
!
! 1. Review and commit these changes
! 2. Push your changes up to a Github repository
! 3. Follow the docker instructions on
! https://teacherspayteachers.atlassian.net/wiki/spaces/SER/pages/1521090593/Getting+started+Create+a+new+serverless+service#Build-and-push-your-project-to-DockerHub
! 4. Deploy to an ODE with `tpt project push`
! 5. Monitor the status of your ODE deploy with:
! kubectl get pods --namespace #{tpt_user_alias} | grep #{Tpt::Rails.app_name}
! 6. When your ODE is ready you can visit it here:
! http://#{Tpt::Rails.app_name}--#{tpt_user_alias}.ode.tptpm.info/#{Tpt::Rails::Engine.instance.routes.url_helpers.health_check_path}
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MESSAGE
end
|