Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-magnumclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kubernetes
python-magnumclient
Commits
8c6c1d7c
Commit
8c6c1d7c
authored
3 years ago
by
Stavros Moiras
Browse files
Options
Downloads
Patches
Plain Diff
OIDC support for python-magnumclient
parent
6d1a386e
Branches
cern/ussuri
No related tags found
1 merge request
!5
OIDC support for python-magnumclient
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
magnumclient/common/utils.py
+51
-4
51 additions, 4 deletions
magnumclient/common/utils.py
magnumclient/osc/v1/clusters.py
+16
-1
16 additions, 1 deletion
magnumclient/osc/v1/clusters.py
with
67 additions
and
5 deletions
magnumclient/common/utils.py
+
51
−
4
View file @
8c6c1d7c
...
@@ -160,11 +160,11 @@ def handle_json_from_file(json_arg):
...
@@ -160,11 +160,11 @@ def handle_json_from_file(json_arg):
def
config_cluster
(
cluster
,
cluster_template
,
cfg_dir
,
force
=
False
,
def
config_cluster
(
cluster
,
cluster_template
,
cfg_dir
,
force
=
False
,
certs
=
None
,
use_keystone
=
False
):
certs
=
None
,
use_keystone
=
False
,
use_oidc
=
False
,
oidc_browser
=
False
):
"""
Return and write configuration for the given cluster.
"""
"""
Return and write configuration for the given cluster.
"""
if
cluster_template
.
coe
==
'
kubernetes
'
:
if
cluster_template
.
coe
==
'
kubernetes
'
:
return
_config_cluster_kubernetes
(
cluster
,
cluster_template
,
cfg_dir
,
return
_config_cluster_kubernetes
(
cluster
,
cluster_template
,
cfg_dir
,
force
,
certs
,
use_keystone
)
force
,
certs
,
use_keystone
,
use_oidc
,
oidc_browser
)
elif
(
cluster_template
.
coe
==
'
swarm
'
elif
(
cluster_template
.
coe
==
'
swarm
'
or
cluster_template
.
coe
==
'
swarm-mode
'
):
or
cluster_template
.
coe
==
'
swarm-mode
'
):
return
_config_cluster_swarm
(
cluster
,
cluster_template
,
cfg_dir
,
return
_config_cluster_swarm
(
cluster
,
cluster_template
,
cfg_dir
,
...
@@ -172,7 +172,7 @@ def config_cluster(cluster, cluster_template, cfg_dir, force=False,
...
@@ -172,7 +172,7 @@ def config_cluster(cluster, cluster_template, cfg_dir, force=False,
def
_config_cluster_kubernetes
(
cluster
,
cluster_template
,
cfg_dir
,
def
_config_cluster_kubernetes
(
cluster
,
cluster_template
,
cfg_dir
,
force
=
False
,
certs
=
None
,
use_keystone
=
False
):
force
=
False
,
certs
=
None
,
use_keystone
=
False
,
use_oidc
=
False
,
oidc_browser
=
False
):
"""
Return and write configuration for the given kubernetes cluster.
"""
"""
Return and write configuration for the given kubernetes cluster.
"""
cfg_file
=
"
%s/config
"
%
cfg_dir
cfg_file
=
"
%s/config
"
%
cfg_dir
if
cluster_template
.
tls_disabled
or
certs
is
None
:
if
cluster_template
.
tls_disabled
or
certs
is
None
:
...
@@ -193,7 +193,54 @@ def _config_cluster_kubernetes(cluster, cluster_template, cfg_dir,
...
@@ -193,7 +193,54 @@ def _config_cluster_kubernetes(cluster, cluster_template, cfg_dir,
"
- name: %(name)s
'
\n
"
"
- name: %(name)s
'
\n
"
%
{
'
name
'
:
cluster
.
name
,
'
api_address
'
:
cluster
.
api_address
})
%
{
'
name
'
:
cluster
.
name
,
'
api_address
'
:
cluster
.
api_address
})
else
:
else
:
if
not
use_keystone
:
if
use_oidc
:
# If cluster has the 'oidc_client_id' set then there is a custom client id
clientid
=
cluster
.
labels
.
get
(
'
oidc_client_id
'
)
if
not
clientid
:
# If not, then everything is managed by magnum, thus we add "oidc" and the cluster uuid (convention)
clientid
=
"
openstack-magnum-
"
+
cluster
.
uuid
if
oidc_browser
:
# Browser will pop up automatically during authentication
granttype
=
"
auto
"
else
:
# Users will have to follow a link and paste a token from their local browser
granttype
=
"
authcode-keyboard
"
cfg
=
(
"
apiVersion: v1
\n
"
"
clusters:
\n
"
"
- cluster:
\n
"
"
certificate-authority-data: %(ca)s
\n
"
"
server: %(api_address)s
\n
"
"
name: %(name)s
\n
"
"
contexts:
\n
"
"
- context:
\n
"
"
cluster: %(name)s
\n
"
"
user: oidc-user
\n
"
"
name: default
\n
"
"
current-context: default
\n
"
"
kind: Config
\n
"
"
preferences: {}
\n
"
"
users:
\n
"
"
- name: oidc-user
\n
"
"
user:
\n
"
"
exec:
\n
"
"
apiVersion: client.authentication.k8s.io/v1beta1
\n
"
"
args:
\n
"
"
- get-token
\n
"
"
- --oidc-issuer-url=https://auth.cern.ch/auth/realms/cern
\n
"
"
- --oidc-client-id=%(client)s
\n
"
"
- --grant-type=%(granttype)s
\n
"
"
command: kubectl-oidc_login
\n
"
"
env: null
\n
"
%
{
'
name
'
:
cluster
.
name
,
'
client
'
:
clientid
,
'
granttype
'
:
granttype
,
'
api_address
'
:
cluster
.
api_address
,
'
ca
'
:
base64
.
encode_as_text
(
certs
[
'
ca
'
])})
elif
not
use_keystone
:
cfg
=
(
"
apiVersion: v1
\n
"
cfg
=
(
"
apiVersion: v1
\n
"
"
clusters:
\n
"
"
clusters:
\n
"
"
- cluster:
\n
"
"
- cluster:
\n
"
...
...
This diff is collapsed.
Click to expand it.
magnumclient/osc/v1/clusters.py
+
16
−
1
View file @
8c6c1d7c
...
@@ -376,6 +376,19 @@ class ConfigCluster(command.Command):
...
@@ -376,6 +376,19 @@ class ConfigCluster(command.Command):
dest
=
'
use_keystone
'
,
dest
=
'
use_keystone
'
,
default
=
False
,
default
=
False
,
help
=
_
(
'
Use Keystone token in config files.
'
))
help
=
_
(
'
Use Keystone token in config files.
'
))
parser
.
add_argument
(
'
--use-oidc
'
,
action
=
'
store_true
'
,
dest
=
'
use_oidc
'
,
default
=
False
,
help
=
_
(
'
Use oidc cluster config.
'
))
parser
.
add_argument
(
'
--oidc-browser
'
,
action
=
'
store_true
'
,
dest
=
'
oidc_browser
'
,
default
=
False
,
help
=
_
(
'
Changes the default oidc authentication method from keyboard to browser
'
))
return
parser
return
parser
...
@@ -425,7 +438,9 @@ class ConfigCluster(command.Command):
...
@@ -425,7 +438,9 @@ class ConfigCluster(command.Command):
print
(
magnum_utils
.
config_cluster
(
print
(
magnum_utils
.
config_cluster
(
cluster
,
cluster_template
,
parsed_args
.
dir
,
cluster
,
cluster_template
,
parsed_args
.
dir
,
force
=
parsed_args
.
force
,
certs
=
tls
,
force
=
parsed_args
.
force
,
certs
=
tls
,
use_keystone
=
parsed_args
.
use_keystone
))
use_keystone
=
parsed_args
.
use_keystone
,
use_oidc
=
parsed_args
.
use_oidc
,
oidc_browser
=
parsed_args
.
oidc_browser
))
class
ResizeCluster
(
command
.
Command
):
class
ResizeCluster
(
command
.
Command
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment